C# TWAIN 交互

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/476084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 04:55:19  来源:igfitidea点击:

C# TWAIN interaction

c#wpfimagingimage-scannertwain

提问by Valentin Vasilyev

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

我正在尝试设置一个使用代码项目中的TWAIN示例的 C# 应用程序

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

这工作正常,除了我需要转换FormIMessageFilter并调用IMessageFilter.PreFilterMessage()以捕获 TWAIN 回调。
另外我需要通过调用来开始这个过滤

Application.AddMessageFilter();

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

有没有办法在 WPF 窗口中做同样的事情?(添加消息过滤器并捕获 TWAIN 回调)。

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

另一个完全高级的问题:有人知道替代 C# TWAIN 库\包装器吗?

Thank you.

谢谢你。

采纳答案by csgero

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

你可以在ComponentDispatcher.ThreadFilterMessage活动中尝试一下。
据我了解,它在WPF 中的作用Application.AddMessageFilter()WinForms 中的作用相同。

回答by driAn

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

我认为 TWAIN 已过时。也许看看WIA,它从 WinXP 开始就完成了这项工作。codeproject 上也有一个示例。关于 WPF 相关问题,不知道,我只在 windows 窗体应用程序中使用它。

回答by Luke Quinane

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

我刚刚将 Thomas Scheidegger 的文章 ( CodeProject: .NET TWAIN image scan) 中的代码打包到github 项目中

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

我已经稍微清理了 API 并添加了 WPF 支持,所以请检查一下。:)

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

它有一个简单的 WPF 应用程序,显示了消息过滤如何与 WPF 配合使用。