Home › Forums › TWAIN Classic › (un)Responsive data source GUI while batch-scanning
- This topic has 1 reply, 2 voices, and was last updated 10 years, 3 months ago by MarkM.
- AuthorPosts
Hi all,
i am working on a twain data source that takes quite some time between two pages.
My problem is that the applications are usually asking for the next image immediately,
so i need to block in “transferNativeImage”, waiting for the next image to become ready.
So far, this works nicely, but the datasources ui is does not receive input until the scan
operation is terminated by the application. But i would like to implement a “stop” button into
my data source UI. I saw other manufacturers UI to be responsive during a batch scan with
the same application, so i tried using PeekMessage/TranslateMessage/DispatchMessage within
my loop waiting for the image. This seems to be working, but only for a few seconds before
it corrupts the heap.
I read a lot around this forum so i already know that twain is somewhat tricky with regards to
the windows messages.
I would like to ask for a “good/clean/solid/reliable” way to implement a responsive gui for a data source
during batch scan operation.Thank you,
Best regards,
Sebastian
A lot of applications fall into this trap, processing image transfers within the MSG_XFERREADY handler, which blocks the application’s message pump.
PeekMessage is the way to go, but it should be carefully filtered so that the only message it processes is the one specific to your Cancel button. Don’t translate and don’t dispatch. Act directly on the message. You can find an example here at MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644928(v=vs.85).aspx
- AuthorPosts