C# TWAIN interaction
Asked Answered
N

3

6

I'm trying to set up a C# application which uses TWAIN example from code project

This works fine except that I need to cast Form to IMessageFilter and call IMessageFilter.PreFilterMessage() to catch TWAIN callbacks.
Also I need to start this filtering by calling

Application.AddMessageFilter();

Is there a way to do same thing in WPF Window? (To add message filter and catch TWAIN callbacks).

Another totally high level question: Does anybody know about alternative C# TWAIN libraries\wrappers?

Thank you.

Nika answered 24/1, 2009 at 14:30 Comment(0)
P
4

You could try it with the ComponentDispatcher.ThreadFilterMessage event.
As far as I understand, it serves the same purpose in WPF as Application.AddMessageFilter() in WinForms.

Pr answered 27/1, 2009 at 11:33 Comment(0)
L
9

I've just wrapped up the code from Thomas Scheidegger's article (CodeProject: .NET TWAIN image scanning) into github project

I've cleaned up the API a bit and added WPF support, so check it out. :)

It has a simple WPF application that shows how the message filtering works with WPF.

Lifeless answered 22/6, 2009 at 12:4 Comment(0)
P
4

You could try it with the ComponentDispatcher.ThreadFilterMessage event.
As far as I understand, it serves the same purpose in WPF as Application.AddMessageFilter() in WinForms.

Pr answered 27/1, 2009 at 11:33 Comment(0)
C
0

I thought TWAIN is considered obsolete. Maybe take a look at WIA, that does this job since WinXP. There is also a sample at codeproject. About the WPF related question, no idea, I only used it in windows forms apps.

Cricket answered 24/1, 2009 at 15:39 Comment(3)
driAn, TWAIN is older but not obsolete. It has vast devices support. Also, my scanner does not (oddly) support WIA.Nika
Well, microsoft considers it being obsolete, they suggest using WIA instead.Cricket
Hmm... There's no causal relation between Microsoft opinions and consensus reality, in either direction. I work with TWAIN, and at least for document scanning, WIA is obsolete and has been since it was introduced. They introduced it during a brief phase when they were excited about clobbering Apple. Then the Burning Eye turned to other things, and it has languished ever since. I recommend it for digital cameras though.Dysphasia

© 2022 - 2024 — McMap. All rights reserved.