我仍然試圖找出與此錯誤發生:包含類型不實現接口IMessageFilter
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;
}
我覺得你的一個類需要實現IMessageFilter接口。 – 2013-03-18 09:53:12
我該如何執行?你能告訴我一些例子嗎? – MrKrahoz 2013-03-18 10:16:50
查看本教程以瞭解如何實現接口:http://msdn.microsoft.com/en-us/library/aa288461(v=vs.71).aspx。您需要在您的方法中需要的任何類型上實現'IMessageFilter'接口。你定義的是'Message'和'TwainMessage'類嗎? – 2013-03-18 14:12:12