Download: CTWAINHELPER (including sample code 35K)
The method is as follows:
Call CTWAINHELPER :: Initialize () Determine if there is available device. In the Window Message loop, call CTWAINHELPER :: ProcessMessage () to process the TWAIN message. To get an image, call CTWAINHELPER :: getImage (). If the image is ready (such as the user determines the scan image), the window will receive a WM_COMMAND message, WPARAM is IDC_TWAINHELPER. At this time, the application can call CTWAINHELPER :: TransferImage () Get image to the file.
// message: If the image is ready, the parent window will receive a WM_COMMAND message.
/ / Parameter: Loword (WPARAM) is 0 for IDC_TWAINHELPER, HIWORD (WPARAM) is 0, and after the number of total images
// Return: If you return S_FALSE, the successful image will not be transferred.
// Note: After receiving this message, you can call TransferImage () to get the image into the file.
#define idc_twainhelper 51234
// ctwainhelper class
Class ctwainhelper
{
PUBLIC:
// Initialize the TWAIN library
Static Bool Initialize (HWND HPARENT);
// Function: Handle TWAIN message
// Return: Returns True Representation is a TWAIN message, at which time the parent window should handle this message
// Remarks: This function should be called in the parent window message loop
Static Bool ProcessMessage (Const PMSG PMSGMSG);
// Function: Get an image from the TWAIN device and inform the parent window in the form of a message callback
/ / Parameter: Ucount Specifies the number of images to be acquired, 0 means not specifying a number. This parameter requires equipment support
// Return: Returns True means successful or user cancellation, other representation failed
// Note: If the call is successful, when the image is ready, the parent window will go to the WM_COMMAND message, please refer to IDC_TWAINHELPER.
Static Bool GetImage (uint ucount = 0);
// Transfer image into the file
Static Bool TransferImage (PCTSTR PTZFileName);
// Close the TWAIN dialog
Static void close ();
}