Accusoft.ThumbnailXpress6.ActiveX
Import ThumbnailXpress as a COM Object

1. Importing a Control into Visual C++

The #import directive line can be added to the stdafx.h file to provide the appropriate functionality to all source files in the project.

C++ Example
Copy Code
// This code demonstrates the #import directive used in the stdafx.h file
#if !defined (AFX_STDAFX_H__CEEB89E9_40D9_11D3_9CFE_00400543FF49__INCLUDED_)
#define AFX_STDAFX_H__CEEB89E9_40D9_11D3_9CFE_00400543FF49__INCLUDED_
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <AFXWIN.H; // MFC core and standard components
#include <AFXEXT.H; // MFC extensions
#include <AFXDISP.H; // MFC OLE automation classes
#include <AFXDTCTL.H>; // MFC support for Internet Explorer 4 Common
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <AFXCMN.H> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//#import the ThumbnailXpress DLL here
#import "Accusoft.ThumbnailXpress6.ActiveX.dll"//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined

The #import directive simply points to the ThumbnailXpress control. When the ThumbnailXpress control is imported with the #import directive, the compiler produces 2 files – a .tli and a .tlh file – that together create the necessary COM wrapper for the control’s properties and methods. Since the directive is in your stdafx.h file, the wrappers are immediately available to your other modules. The wrapper code defines COM smart pointers to your .IDL-defined interfaces. To use this COM object, you simply create an instance of the interface you want and then call methods directly by using this instance pointer.

2. Declare a Pointer to the COM Object

After the #import directive is added, a pointer to the ThumbnailXpress COM object must be defined. 

C++ Example
Copy Code
using namespace AccusoftThumbnailXpress6;
#include "..\Include\ThumbnailXpress6Events.h"
class CEventDlg : public CDialog //, CThumbnailXpressEventHandler
{
public:
CThumbnailXpress *ppCThumbnailXpress1;

The ThumbnailXpress6Events.h file contains the CThumbanail class. The CThumbnail class is used to create a ThumbnailXpress COM object and handles ThumbnailXpress events.

3. Initialize COM

The COM library must be initialized before COM functions can be called and it must be closed before the program exits. 

C++ Example
Copy Code
// This is illustrated in the Event.cpp file as follows
BOOL CEventApp::InitInstance()
{
HRESULT hRes = CoInitialize(NULL);
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
CEventDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Closes the COM library on the current apartment,
// unloads all DLLs loaded by apartment,
// frees any other resources that the apartment maintains, and
// forces all RPC connections on the apartment to close.
CoUninitialize();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
} 

4. Create the ThumbnailXpress COM Object

To use ThumbnailXpress, an instance of the ThumbnailXpress COM object must be created. After the object is created, the object’s properties and methods can be used to create your scanning application. In the Event project, the COM object is created in the EventDlg.cpp file as follows:

C++ Example
Copy Code
// Include the ThumbnailXpress COM initialization routines
BOOL CEventDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
ppCThumbnailXpress1 = NULL;
ppCThumbnailXpress6 = NULL; // Initialize the ThumbnailXpress COM interface. MUST be done before creating the first object.
// Create ThumbnailXpress Object 1
ppCThumbnailXpress1 = new CThumbnailXpress(this, 1, m_hWnd, 10, 120, 530, 200);
// NOTE: The run-time licensing shown below are for illustration purposes only.
// For distribution, uncomment and call the SetSolutionName and SetSolutionKey and possibly the SetOEMLicenseKey methods passing the ThumbnailXpress license solution name, solution keys and OEM license key respectively.
//ppCThumbnailXpress1->pThumbnailXpress->SetSolutionName(“ACMEImaging”);
//ppCThumbnailXpress1->pThumbnailXpress->SetSolutionKey(0x1C3A023F, 0xA018F260, 0x37AF0E51, 0x557F2389);
//The next line is only needed to be called for Manually Reported Runtime (Non-Node-Locked) licensing
//ppCThumbnailXpress1->pThumbnailXpress->SetOEMLicenseKey( “1.0.GQCC0EmUgONaI4QDZ32tpGWfpGW4gtbC0iIC0iN4bigYM3m3K5b487QOsAM38O24mUp5bOpD2O240OQ32U2YsUKDKA87MYPGgGgaptMiK5Nv8AI4mYg4m3QvW52DZCPGs4p784mtP4IUgOWiIG0AQYp4052iIAWvNCZfpGWC8vQ5P4ZGKaPAWfbiYfZOI303pOZAgisiNaWA27gGsf8Ob7Zvm5IaKGI4KC8GsG2CWYpGQAg5sUmYWvZCQANig48G2ap4bG0DsO240YsUmtptNiZamCPGbYMfMO83gANAZCN52YbY8U8f8DM4m3g7MYMYWGW5Q7QGWaMiN7MtZfmtgY8AN7NDP7Z4W7sCbGKUPa0im7EDPP");
// For distribution, uncomment and call the SetIXSolutionName, SetIXSolutionKey and possibly the SetIXOEMLicenseKey methods passing the ImagXpress license solution name, solution keys and OEM license key respectively.
//ppCThumbnailXpress1->pThumbnailXpress->SetIXSolutionName(“ACMEImaging”); 
//ppCThumbnailXpress1->pThumbnailXpress->SetIXSolutionKey(0xB0000001, 0xB0000002, 0xB0000003, 0xB0000004);
//The next line is only needed to be called for Manually Reported Runtime (Non-Node-Locked) licensing
//ppCThumbnailXpress1->pThumbnailXpress->SetIXOEMLicenseKey( “1.0.WXPB1EmUgONaI4QDZ32tpGWfpGW4gtbC0iIC0iN4bigYM3m3K5b487QOsAM38O24mUp5bOpD2O240OQ32U2YsUKDKA87MYPGgGgaptMiK5Nv8AI4mYg4m3QvW52DZCPGs4p784mtP4IUgOWiIG0AQYp4052iIAWvNCZfpGWC8vQ5P4ZGKaPAWfbiYfZOI303pOZAgisiNaWA27gGsf8Ob7Zvm5IaKGI4KC8GsG2CWYpGQAg5sUmYWvZCQANig48G2ap4bG0DsO240YsUmtptNiZamCPGbYMfMO83gANAZCN52YbY8U8f8DM4m3g7MYMYWGW5Q7QGWaMiN7MtZfmtgY8AN7NDP7Z4W7sCbGKUPa0im7EDJS");
ppCThumbnailXpress1->pThumbnailXpress->ScrollDirection = TN_Horizontal;
// initialize event related parameters
ppCThumbnailXpress1->SetPaintEvent(Paint);
ppCThumbnailXpress1->SetSelectionIndexChangedEvent(SelectionIndexChanged);
ppCThumbnailXpress1->pThumbnailXpress->EnableEvent(TN_SelectedIndexChange, TRUE);
ppCThumbnailXpress1->SetErrorEvent(Error);
ppCThumbnailXpress1->pThumbnailXpress->EnableEvent(TN_Error , TRUE);
ppCThumbnailXpress1->SetItemCompleteEvent(ItemComplete);
ppCThumbnailXpress1->pThumbnailXpress->EnableEvent(TN_ItemComplete , TRUE);
ppCThumbnailXpress1->SetClickEvent(Click);
ppCThumbnailXpress1->SetDblClickEvent(DblClick);
return TRUE;
// return TRUE unless you set the focus to a control
}

 

5. Use the ThumbnailXpress COM Object to Set Properties and Call Methods

After an instance of the ThumbnailXpress COM object is created, the object can be used to set ThumbnailXpress properties and call its methods.

C++ Example
Copy Code
// In the Event project, this is illustrated in the OnButton1() function shown below. This function is called when the user clicks the button.
void CEventDlg::OnButton1()
{
CEventDlg *p = (CEventDlg *) this;
CListBox *pL = (CListBox *)p->GetDlgItem(IDC_LIST1);
if(ppCThumbnailXpress1)
{
ppCThumbnailXpress1->pThumbnailXpress->AddDirectoryItems("..\\..\\..\\..\\..\\..\\Common\\Images\\*.tif", -1);
if(ppCThumbnailXpress1->pThumbnailXpress->ErrorCode)
pL->SetCurSel(pL->AddString( "***ERROR*** unable to load images from ..\\..\\..\\..\\..\\..\\Common\\Images - ThumbnailXpress #1"));
}
}

6. Delete the ThumbnailXpress COM Object

The ThumbnailXpress COM object must be deleted when it is no longer needed. The object is usually deleted before the application exits.

C++Example
Copy Code
// In the Event project, the COM object is deleted as follows
void CEventDlg::OnDestroy(){
CDialog::OnDestroy();
// Delete our ThumbnailXpress Objects
if(ppCThumbnailXpress1)
{
delete ppCThumbnailXpress1;
}
} 

 

 

 


©2019. Accusoft Corporation. All Rights Reserved.

Send Feedback