gpt4 book ai didi

c# - 包含类型不实现接口(interface) IMessageFilter

转载 作者:太空宇宙 更新时间:2023-11-03 11:07:08 27 4
gpt4 key购买 nike

我仍在尝试找出此错误的原因:

OCR.test.IMessageFilter.PreFilterMessage(ref System.Windows.Forms.Message): containing type does not implement interface System.Windows.Forms.IMessageFilter

这是我的代码:

bool IMessageFilter.PreFilterMessage(ref Message m) // Error with this line
{
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:
{
ArrayList pics = tw.TransferPictures();
EndingScan();
tw.CloseSrc();
picnumber++;
for (int i = 0; i < pics.Count; i++)
{
IntPtr img = (IntPtr)pics[i];
PicForm newpic = new PicForm(img);
newpic.MdiParent = this;
int picnum = i + 1;
//newpic.Text = "ScanPass " + picnumber.ToString() + "_Pic " + picnum.ToString();
newpic.Show();
}
break;
}
}

return true;
}

最佳答案

实现 PreFilterMessage 方法的类需要派生自 IMessageFilter 接口(interface)。你可能错过了

public class Foo: IMessageFilter
{
bool IMessageFilter.PreFilterMessage(ref Message m)
{
// your code
}
}

关于c# - 包含类型不实现接口(interface) IMessageFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15473650/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com