【发布时间】:2010-12-22 12:16:40
【问题描述】:
我正在尝试编译我在此处 (C# TWAIN interaction) 找到的 TwainDotNet 解决方案,但我束手无策。
这个解决方案显然是在 VS 2008 中开发的,我在 2005 年工作(目前没有选择)。 2005 年我可能花了很多时间来编译这一切,并且我已经将我的错误减少到两个,两个错误都是同一个问题。
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace TwainDotNet.WinFroms
{
/// <summary>
/// A windows message hook for WinForms applications.
/// </summary>
public class WinFormsWindowMessageHook : IWindowsMessageHook, IMessageFilter
{
IntPtr _windowHandle;
bool _usingFilter;
public WinFormsWindowMessageHook(Form window)
{
_windowHandle = window.Handle;
}
public bool PreFilterMessage(ref Message m)
{
if (FilterMessageCallback != null)
{
bool handled = false;
FilterMessageCallback(m.HWnd, m.Msg, m.WParam, m.LParam, ref handled);
return handled;
}
return false;
}
public IntPtr WindowHandle { get { return _windowHandle; } }
public bool UseFilter
{
get
{
return _usingFilter;
}
set
{
if (!_usingFilter && value == true)
{
Application.AddMessageFilter(this);
_usingFilter = true;
}
if (_usingFilter && value == false)
{
Application.RemoveMessageFilter(this);
_usingFilter = false;
}
}
}
public FilterMessage FilterMessageCallback
{
get;
set;
}
}
}
在访问委托实例的属性上编译失败。
错误:“TwainDotNet.WinFroms.WinFormsWindowMessageHook.FilterMessageCallback.get”必须声明一个主体,因为它没有标记为抽象或外部
这是该类实现的接口IWindowsMessageHook:
using System;
using System.Collections.Generic;
using System.Text;
namespace TwainDotNet
{
public interface IWindowsMessageHook
{
/// <summary>
/// Gets or sets if the message filter is in use.
/// </summary>
bool UseFilter { get; set; }
/// <summary>
/// The delegate to call back when the filter is in place and a message arrives.
/// </summary>
FilterMessage FilterMessageCallback { get; set; }
/// <summary>
/// The handle to the window that is performing the scanning.
/// </summary>
IntPtr WindowHandle { get; }
}
public delegate IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled);
}
我承认自己是代理新手,我在这里不知所措。如何在 VS 2005 中复制此功能?
感谢您的时间。
【问题讨论】:
标签: c# visual-studio-2005 delegates callback twain