Home › Forums › TWAIN Classic › Twain Data Source in Windows 7
- This topic has 4 replies, 2 voices, and was last updated 11 years, 2 months ago by spike.
- AuthorPosts
Is there any known issue with Sample Twain Data Source on Windows 7? I have spent 2 full days digging this. I’m using .NET 4.0 with C# and VS2010 to write an application that could talk to the Sample DS and get that single image from it. But I get a Failure status in DataSource.Enable() function. I have tried both enabling and disabling UI dialog, but it doesn’t help. When I enable UI, the TWAIN DS dialog appears, showing all the settings of the Sample DS, but clicking the Scan button doesn’t do anything.
Interestingly, the same application works just fine on Windows XP. Also, the Twain sample application that is bundled with the Sample DS can talk to the DS without any problem.
Prompt answer will hugely be appreciated.
Shujaat
That sounds like it could be a message handling problem, or an XFERREADY handling problem.
When you enable with the UI, is the dialog ‘live’ and responsive otherwise? You can change settings?
Or the problem appears only when you click the Scan button?I assume you are building your app with Target=x86.
Which TWAIN Manager are you using, twain_32.dll, or twaindsm.dll?
Does your application describe itself as a TWAIN 2.0 app or not?
How are you handling MSG_XFERREADY – do you use message forwarding (MSG_PROCESSEVENT) or does your code set up a call-back handler using MSG_REGISTER_CALLBACK?Thanks Spike. Answering your questions:
Yes, the dialog is LIVE. I can click on things and change settings where available. But clicking the Scan (or Cancel) button do not do anything, as if nothing had happened.
Yes. The target is x86.
Which TWAIN Manager are you using, twain_32.dll, or twaindsm.dll?
How do I find out the TWAIN Manager I’m using and how does an application describe itself as a TWAIN 2.0 app?
About those message handlers, this is a managed .net C# application, so all those kind of stuff is normally handled by default.
In fact, TWAIN’s UI settings are sometimes unchangable. They DO respond to keyboard and mouse, but do not allow changing the selected values.
I also found that the underlying DLL that is being called is “twain_32.dll”, but “twaindsm.dll” is also available in my System32 directory.
About those message handlers, this is a managed .net C# application, so all those kind of stuff is normally handled by default.
That’s not correct in the case of TWAIN, which requires that certain Windows messages be handled in a TWAIN-specific way.
Neither Windows nor .NET will handle those messages correctly by default.But you said you can take your .exe, move it to Windows XP and run it, and it works and scans?
That would mean it isn’t a message-handling problem.Well. You should have in your TWAIN-related code, someplace where you call TWAIN with pAppId, pSrcId, DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, &event
Or the equivalent in C#.
If that call isn’t being made *somewhere* in your app while the scanner is enabled, then the dialog won’t work right.
That call receives messages back from TWAIN in the event.TWMessage field, so there should be a switch or if after that, that looks for MSG_XFERREADY.
If MSG_XFERREADY isn’t being handled, scanning will never start.Find that code and verify it. If necessary, breakpoint it to be sure it is being hit – the MSG_PROCESSEVENT call repeatedly while the scanner dialog is visible, and the MSG_XFERREADY code when you click the Scan button.
If that call is nowhere in your code, see the TWAIN Spec, around 3-8: “How to Modify the Event Loop for Microsoft Windows” – and take a look at (for example) TwainDotNet.
For example, you can see part of the message-processing stuff of TwainDotNet here:
https://code.google.com/r/wsmwlh-twaindotnet/source/browse/TwainDotNet/DataSourceManager.cs?spec=svn9fdc61f462c2919dbad7717dbe1d736e6a5a5021&r=9fdc61f462c2919dbad7717dbe1d736e6a5a5021- AuthorPosts