Visual Basic and DTWAIN Notifications
Many times, the program that acquires an image needs to know the progress of the acquisition while it is being acquired. The way that an application is informed of the acquisition process is by either intercepting messages within a Window procedure, or setting up a callback function. Please see DTWAIN Notification processing for more details.
If you are using Visual Basic 5.0 or above, the only way that we have found notifications to work correctly is to use the callback (or function pointer) method of retrieving the DTWAIN notifications. To set up a callback function in VB 6.0 and below, the DTWAIN_SetCallback function must be used, and the callback function must be the following prototype:
For Visual Basic 6.0 and below: Function CallbackProc(ByVal WParam As Long, ByVal LParam As Long, ByVal UserData As Long) As Long
When calling DTWAIN_SetCallback, the AddressOf operator on the argument to DTWAIN_SetCallback is used to set the function pointer:
DTWAIN_SetCallback(AddressOf MyCallback, 0)
Function pointers in Visaul Basic are somewhat strict and more restrictive than function pointers in 'C' or C++. Please consult the Visual Basic documentation that comes with the VB software for more information on function pointers.
If you are using a version of Visual Basic below 5.0, the callback mechanism is not available. However, there are OCX and VBX controls called "message blasters" that allow retrieval of messages. However, these "message blasters" have not been tested with DTWAIN
For Visual Basic .NET/2005/2008/2010 and later Function CallbackProc(ByVal WParam As Integer, ByVal LParam As Integer, ByVal UserData As Integer) As Integer
For both Visual Basic and VB .NET, MyCallback is a function that has the same parameters and return type as CallbackProc. The MyCallback function is then called anytime DTWAIN sends a message back to the application. The example program in the VisualBasic\examples\Notifications subdirectory has an example of using the callback mechanism.
|