The LEADTOOLS WIA driver is available in LEADTOOLS version 16 or higher.
This tutorial shows you a quick and easy way to generate a WIA program. For more in-depth WIA programming, refer to the WIA demo.
Take the following steps to create and run a program that implement LEADTOOLS WIA features:
WiaEnumDevTutor
. Examples\ClassLibrary\MSVC
directory of your LEAD installation. For example, if you installed LEADTOOLS in C:\LEADTOOLS21\
, enter C:\LEADTOOLS21\Examples\ClassLibrary\MSVC
, then click OK. Then click Next. WiaEnumDevTutor.h
. Add the following line immediately before the class CWiaEnumDevTutorApp
declaration, (keep in mind, you may have to change the path to where the header files reside):
#include "..\..\..\..\include\ClassLib\ltwrappr.h"
Click the Class View tab.
WiaEnumDevTutor
classes branch.CWiaEnumDevTutorApp
, and then double-click the CWiaEnumDevTutorApp(void)
constructor.Add the following lines after //TODO: add construction code here
:
LBase::LoadLibraries(LT_ALL_LEADLIB);
L_TCHAR * pszLicenseFile = L"Replace this with the path to the LEADTOOLS license file";
L_TCHAR * pszDeveloperKey = L"Replace this with your developer key";
LSettings::SetLicenseFile(pszLicenseFile, pszDeveloperKey);
Create a new file called Imports.cpp
and place it beside your project files.
Imports.cpp
.Imports.cpp
in the Solution Explorer and add the following lines:
#include "StdAfx.h"
#if defined(WIN64)
#pragma comment(lib, "..\\..\\..\\..\\Lib\\CDLLVC10\\x64\\Ltwvc_x.lib")
#else
#pragma comment(lib, "..\\..\\..\\..\\Lib\\CDLLVC10\\Win32\\Ltwvc_u.lib")
#endif // #if defined(WIN64)
Click the Solution Explorer tab.
WiaEnumDevTutorDlg.h
file to open it.Add the following class declaration before the CWiaEnumDevTutorDlg
class.
class LMyWia : public LWia
{
LEAD_DECLAREOBJECT(LMyWia);
public:
LMyWia();
virtual ~LMyWia();
virtual L_INT EnumDevicesCallBack(pLWIADEVICEID pDeviceID);
};
Click the Solution Explorer tab.
WiaEnumDevTutorDlg.cpp
file to open it.Add the following class:
LEAD_IMPLEMENTOBJECT(LMyWia);
LMyWia::LMyWia()
{
EnableCallBack(TRUE);
}
LMyWia::~LMyWia()
{
}
L_INT LMyWia::EnumDevicesCallBack(pLWIADEVICEID pDeviceID)
{
L_TCHAR szDeviceInfo[MAX_PATH] = TEXT("");
If(pDeviceID != NULL)
{
wsprintf(szDeviceInfo,
TEXT("Device ID: %s\nDevice Name: %s\nDevice Desc.:%s"),
pDeviceID->pszDeviceId,
pDeviceID->pszDeviceName,
pDeviceID->pszDeviceDesc);
MessageBox(szDeviceInfo, TEXT("Available WIA Devices"), MB_OK);
}
return WIA_SUCCESS;
}
Click the Class View tab.
CWiaEnumDevTutorDlg
and select Add "Add Variable..."LMyWia
, and for the Variable Declaration put m\_MyWia
. Leave Access as Public
and click OK.Click to open the CWiaEnumDevTutorDlg branch. Double-click the OnInitDialog()
function and add the following code after the line reading:
// TODO: Add extra initialization here
m_MyWia.InitSession(WiaVersion1);
Right-click the CWiaEnumDevTutorDlg
branch, and choose Properties.
WM\_DESTROY
and choose OnDestroy.Add the following code after the opening bracket {:
m_MyWia.EndSession();
LBase::UnloadLibraries(LT_ALL_LEADLIB);
Click the Solution Explorer tab.
WiaEnumDevTutor.rc
file to open it, then double-click Dialog, and then double-click IDD\_WIAENUMDEVTUTOR\_DIALOG
.Now, drag and drop 1 button, and change its properties as follows:
a. Control: Button1
b. ID: IDC_ENUM_WIA_DEVICE
c. Caption: Enumerate WIA Devices
From the View menu, select the Other Windows menu, then select the Resource View menu, then select Dialog, and select IDD\_WIAENUMDEVTUTOR\_DIALOG
m_MyWia.EnumDevices();