如何判断一台机器是否连接了扫描仪,我使用“吐温" [英] how to judge one machine connect a scanner,I use the "twain"
本文介绍了如何判断一台机器是否连接了扫描仪,我使用“吐温"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在我还没有将清理器连接到我的机器上
我的代码-单击扫描按钮:
now I have not connect a sanner to my machine
my code --click the scan button:
private void btnScan_Click(object sender, EventArgs e)
{
if (!msgfilter)
{
this.Enabled = false;
msgfilter = true;
Application.AddMessageFilter(this);
}
//i want judge if one scanner is connected first,if no ,then do noting……
tw.Acquire();
this.txtTotalPages.Enabled = false;
}
// then do loop next fun--
bool IMessageFilter.PreFilterMessage(ref Message m)
{
//
TwainCommand cmd = tw.PassMessage(ref m);
if (cmd == TwainCommand.Not)
return false;
switch (cmd)
{
case TwainCommand.CloseRequest:
{
EndingScan();
tw.CloseSrc();
break;
}
case TwainCommand.CloseOk:
{
EndingScan();
tw.CloseSrc();
break;
}
case TwainCommand.DeviceEvent:
{
break;
}
case TwainCommand.TransferReady:
{
推荐答案
非常感谢,我在跟踪代码时发现了麻烦,当我没有连接一台扫描仪时,我单击了sanner按钮,它将循环执行功能----
Thanks very much,I have found the trouble when I track the code,when I did not connect one scanner,I click the sanner button ,it will do loop the funntion----
bool IMessageFilter.PreFilterMessage(ref Message m) ...
为什么循环,我跟踪我的代码并发现它执行了代码://
why do loop that,I track my code and found it perform the code: //
TwainCommand cmd = tw.PassMessage(ref m);
if (cmd == TwainCommand.Not)
return false;
现在我将其更改如下:
now I changed it like below:
if (cmd == TwainCommand.Not)
{
EndingScan();
tw.CloseSrc();
return false;
}
现在可以了,这是我的错,我太粗心了……
再次感谢…………
now it is ok,it is my fault,I am so careless……
thank s again……
这篇关于如何判断一台机器是否连接了扫描仪,我使用“吐温"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文