Application Message Loop Issues

Top 

The first problem that many TWAIN programs encounter is the issue of changing the main application loop.  To acquire images, it is mandatory that the messages sent by the TWAIN are processed by the application.  With DTWAIN, this step is not necessary, since DTWAIN has an optional built-in application loop.  Unlike traditional TWAIN applications, altering the main application is optional with DTWAIN.  However it is always best to consider altering the message loop (if your programming language allows you to do so).

 

If your programming language can alter the main Application Message Loop:

If you use a language that allows programmable access to the application's main message loop, you can alter the message loop while DTWAIN handles all of the tricky details.  These languages include C and C++.  Even though message loop alteration in DTWAIN is not necessary, under certain conditions it may be desirous for the TWAIN application to handle the necessary changes to the application's message loop.  One reason is that the TWAIN specification documents this method as the 'safest' way to acquire images without causing programming problems.

 

If your language cannot alter the Main Application Message Loop or you do not desire to alter the loop within your application:

If you use a language that does not allow easy access to the main application's message queue (such as Borland Delphi, Visual Basic, Foxpro, SQL Windows, various 'script' languages, etc.), or if you desire not to alter the application's main message loop, you must use DTWAIN using the built-in DTWAIN Modal Application Message Loop.

 

To inform DTWAIN of which method of TWAIN application loop processing that is to be done, the DTWAIN_SetTwainMode is used to set the mode.  This should be called before acquiring any images using the DTWAIN Acquisition functions.