I'm attempting to get the TwainDotNet solution I found here (http://stackoverflow.com/questions/476084/c-twain-interaction) to compile, and I'm at my wits end.
This solution was obviously developed in VS 2008, and I'm working in 2005 (no choice at the moment). I've spent probably WAY to much time getting this all to compile in 2005, and I've whittled my errors down to two, both errors being the same one issue.
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;
}
}
}
The compile fails on the property accessing the delegate instance.
ERROR: 'TwainDotNet.WinFroms.WinFormsWindowMessageHook.FilterMessageCallback.get' must declare a body because it is not marked abstract or extern
Here is the interface IWindowsMessageHook that this class implements:
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);
}
I admit to being a delegate newbie, and I'm at a loss here. How can I duplicate this functionality in VS 2005?
Thanks for the time.