Note: The purpose of this TWAIN tutorial is to provide you a quick and easy way to generate a TWAIN program. For more in depth TWAIN programming, refer to the TWAIN demo.
To acquire a FAST TWAIN scan using LEADTOOLS:
| 
 1.  | 
 Create a new directory in the \Examples\CDLL directory called TwainTutorial2  | 
| 
 2.  | 
 Copy everything in the SimpleLoad directory into the TwainTutorial2 directory.  | 
| 
 3.  | 
 Compile the project as it is and run SimpleLoad.exe to familiarize yourself with the basic program.  | 
| 
 4.  | 
 In the Imports.cpp, add the following lines:  | 
#if defined(WIN64)
…
…
#else
…
…
#pragma comment(lib, "..\\..\\..\\Lib"L_VER_DESIGNATOR"\\CDLL\\Win32\\Lttwn_u.lib")
#endif // #if defined(WIN64)
| 
 5.  | 
 Add the following line in StdAfx.h in the TwainTutorial2 directory:  | 
#include "..\..\..\include\lttwn.h"
| 
 6.  | 
 Define the following global variables in Ezfunc.h in the TwainTutorial2 directory:  | 
HTWAINSESSION hSession;
FASTCONFIG    BestConfig;
Also, add the following defines:
#define IDM_SELECT_SOURCE 200
#define IDM_FIND_FAST_CONFIG 201
#define IDM_ACQUIRE_FAST_CONFIG 202
| 
 7.  | 
 Edit EZFUNC.RC file in the TwainTutorial directory and add the following lines:  | 
#include "EZFUNC.H"
MAIN_MENU MENU
BEGIN
MENUITEM "Select Source" IDM_SELECT_SOURCE
MENUITEM "Find Fast Config" IDM_FIND_FAST_CONFIG
MENUITEM "Acquire Fast Config" IDM_ACQUIRE_FAST_CONFIG
END
| 
 8.  | 
 In the InitApplication function change the line:  | 
wcWindowClass.lpszMenuName = NULL;  /* No menu */
to be
wcWindowClass.lpszMenuName = TEXT("MAIN_MENU");
| 
 9.  | 
 In the MainWndProc function and before the handling of the WM_PALETTECHANGED message add the following code:  | 
   case WM_COMMAND: 
      {
         switch (LOWORD(wParam)) 
         {
         case IDM_SELECT_SOURCE: 
            {
            }
            break; 
         case IDM_FIND_FAST_CONFIG: 
            {
            }
            break; 
         case IDM_ACQUIRE_FAST_CONFIG: 
            {
            }
            break; 
         }
      }
      break;
| 
 10.  | 
 In the WM_CREATE message handler add the following code at the end of it (after SendMessage (hWnd, WM_QUERYNEWPALETTE, 0, 0L);):  | 
APPLICATIONDATA AppData; 
AppData.uStructSize = sizeof(APPLICATIONDATA);
AppData.hWnd = hWnd; 
lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc.")); 
lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Test Applications"));
lstrcpy (AppData.szVersionInfo, TEXT("Version 1.0"));
lstrcpy (AppData.szAppName, TEXT("TWAIN Test Application"));
nRet = L_TwainInitSession(&hSession, &AppData); 
if (nRet != SUCCESS) 
   return FALSE; 
   
| 
 11.  | 
 In the WM_DESTROY message handler add the following code at the end of it (before the PostQuitMessage (0);):  | 
L_TwainEndSession(&hSession);
| 
 12.  | 
 In the IDM_SELECT_SOURCE menu handler add the following code:  | 
case IDM_SELECT_SOURCE:
   {
      nRet = L_TwainSelectSource(hSession, NULL); 
   }
   break;
| 
 13.  | 
 In the IDM_FIND_FAST_CONFIG menu handler add the following code:  | 
case IDM_FIND_FAST_CONFIG: 
   {
      pFASTCONFIG pTestConfigs = NULL;
      L_INT       nTestConfigsCount = 0;
      nRet = L_TwainFindFastConfig(hSession,
                                   TEXT("c:\\temp"),
                                   LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
                                   8, 5, NULL, 0,
                                   &pTestConfigs,
                                   &nTestConfigsCount,
                                   &BestConfig,
                                  sizeof(FASTCONFIG),
                                   NULL,
                                   NULL);
      if (nRet == SUCCESS)
         MessageBox(hWnd, TEXT("Find Fast Configuration process completed"), TEXT("Fast Config"), MB_OK);
      else
         MessageBox(hWnd, TEXT("An error occurred during the Finding Fast Configuration process."), TEXT("Fast Config"), MB_OK);
   }
   break;
| 
 14.  | 
 In the IDM_ACQUIRE_FAST_CONFIG menu handler add the following code:  | 
case IDM_ACQUIRE_FAST_CONFIG: 
   {
      nRet = L_TwainAcquireMulti(hSession,
                                 TEXT("c:\\temp\\testconfig.tif"),
                                 LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
                                 BestConfig.uTransferMode,
                                 BestConfig.nFileFormat,
                                 BestConfig.nBitsPerPixel,
                                 TRUE,
                                 BestConfig.ulBufferSize,
                                 TRUE,
                                 NULL,
                                 NULL);
      if (nRet == SUCCESS)
         MessageBox(hWnd, TEXT("Image acquisition using the Fast TWAIN Configuration is completed."), TEXT("Fast Config"), MB_OK);
      else
         MessageBox(hWnd, TEXT("An error occurred while acquiring images using the Fast TWAIN Configuration."), TEXT("Fast Config"), MB_OK);
   }
   break;
| 
 15.  | 
 Compile and test the program.  |