Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# TWAIN interaction

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.

like image 918
Valentin V Avatar asked Jan 24 '09 14:01

Valentin V


Video Answer


3 Answers

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.

like image 72
Luke Quinane Avatar answered Oct 24 '22 08:10

Luke Quinane


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.

like image 45
csgero Avatar answered Oct 24 '22 07:10

csgero


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.

like image 29
driAn Avatar answered Oct 24 '22 07:10

driAn