[译]使用TWAIN的复印实用程序
By robot-v1.0
本文链接 https://www.kyfws.com/applications/a-copy-utility-using-twain-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 3 分钟阅读 - 1087 个词 阅读量 0[译]使用TWAIN的复印实用程序
原文地址:https://www.codeproject.com/Articles/7720/A-Copy-Utility-using-TWAIN
原文作者:Holger Kloos
译文由本站 robot-v1.0 翻译
前言
Example for a simple encapsulation of the TWAIN interface
TWAIN接口的简单封装示例
介绍(Introduction)
TWAIN界面允许访问大多数图像源.就计算机编程而言,这是一个非常古老的标准,因此使用C接口和Windows消息(在Windows系统上)进行通信.本示例说明如何使用C ++接口封装TWAIN接口.(The TWAIN interface allows the access to most image sources. It is a quite old standard in terms of computer programming and therefore uses a C interface and Windows messages (on Windows systems) for communication. This example shows how to encapsulate the TWAIN interface with a C++ interface.)
背景(Background)
有关TWAIN规范的详细信息,请查看TWAIN的主页.(For details of the TWAIN specification please take a look at the homepage of the) TWAIN工作组(TWAIN Working Group) .我显示的此示例引用了此文档的1.9版.它很容易阅读,但是界面是一个广泛的界面,它也主要使用一种界面功能仅控制图像源:(. This example I show refers to version 1.9 of this document. It is quite easy to read, but the interface is a broad one also it mainly uses one interface function to control the image source only:)
// from twain.h:
...
#ifdef _MSWIN_
TW_UINT16 FAR PASCAL DSM_Entry( pTW_IDENTITY pOrigin,
pTW_IDENTITY pDest,
TW_UINT32 DG,
TW_UINT16 DAT,
TW_UINT16 MSG,
TW_MEMREF pData);
typedef TW_UINT16 (FAR PASCAL *DSMENTRYPROC)(pTW_IDENTITY, pTW_IDENTITY,
TW_UINT32, TW_UINT16,
TW_UINT16, TW_MEMREF);
#else /* _MSWIN_ */
...
** 吐温(twain.h) TWAIN工作组(TWAIN Working Group) ## 使用代码(Using the code)
[Deutsch]
value=1
*TCopy.ini(TCopy.ini)*这个样本中最有趣的一类是(The most interesting class of this sample is) CTwainPP
隐藏所有TWAIN内容.在运行时,它将映射Twain源管理器(hiding all the TWAIN stuff. At runtime it maps the Twain Source Manager)TWAIN_32.DLL(TWAIN_32.DLL)连接到TWAIN系统.它使用一些帮助程序类.其中之一是(to connect to the TWAIN system. It uses some helper classes. One of them is) CTwainEventHandler
它将接收图像源发送回的所有反馈窗口消息,并将它们转发给(which receives all the feedback windows messages sent back by the image source and forward them to) CTwainPP
.为此目的,此类需要一个宿主窗口,在该宿主窗口中挂钩其自己的消息回调函数.此技术允许为此目的回收主对话框窗口,但很容易用隐藏的附加窗口替换此机制.(. For this purpose this class needs a host window where it hooks its own message callback function into.This technique allows to recycle the main dialog window for this purpose but it is easy to replace this mechanism with a hidden additional window.)
在TWAIN接口旁边,示例应用程序使用该类(Beside the TWAIN interface the sample application uses the class) CDIBUse
用于处理设备独立位图(DIB)和此类(for the handling of a Device Independent Bitmap (DIB) and the class) CPrinterAccess
控制打印机并打印出DIB.(to control the printer and to print out a DIB.The class) CShowBitmapCtrl
是专业的(is a specialized) CStatic
控件以显示DIB.(control to display a DIB.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 Windows Visual-Studio Dev 新闻 翻译