Home › Forums › TWAIN Classic › Command line twain › Reply To: Command line twain
problems with the code,
you havent provided a modified messageloop. You’re passing in a handle to twain, but you aren’t filtering(processing) messagages.
If you want the library to handle all of the twain calls for you then the class that talks to twain (in .net) should inherit from System.Windows.Forms.Form and Implement IMessageFilter.
Then in PreFilterMessage (that Implements MessageFilter.PreFilterMEssage) you’ll filter the messages that are coming in and do the appropriate thing. In that case you won’t pass a handle from the form to the library as the library will be using the handle to the above class to pass to twain
-or-
Or you can add Implements IMessageFilter to the main form (the one with the big red Scan button) and process the messages there.
In my mind the first alternative offers much more flexibility as the class can then be used from other project types that don’t (by default) have the messageloop appropriate for use with twain (like the Console Application or Windows Service templates).
I skimmed thru a bit of the code for some problems that seem to be common and a couple of things caught my eye.
Your TwCapability class doesn’t look right, if memory servers there should be a lookup (a huge select case statement or something) where you determine how much memory to reserve based on the cap that you’re trying to create
Your TwFix32 *may* work, but I think you are going to be off in your calculations when|if you encounter a negative number. TwFix32 is somewhat critical as a great deal of twain uses this structure or class – you might have it right, but I would double check.
Your TwImageInfo class doesn’t seem to be defined correctly, XResolution and YResolution are Fix32 not Int32.
There may be more (or the rest may be correct), but that was all I had time to look at right now. Feel free to catch me over IM or ask more questions here until you run out of questions.
.