Here it is:
//*******************************************************//
using System;
namespace CSToolWinAddin
{
/// <summary>
/// Summary description for HookMessage.
/// </summary>
///
using System.Runtime.InteropServices;
delegate void MsgEventHandler(object source, MsgEventArgs e);
public class MsgEventArgs: EventArgs
{
public int hWnd;
public int uMsg;
public int wParam;
public int lParam;
public MsgEventArgs(int hWnd, int uMsg, int wParam, int lParam)
{
this.hWnd = hWnd;
this.uMsg = uMsg;
this.wParam = wParam;
this.lParam = lParam;
}
}
class HookMessage
{
const int GWL_WNDPROC= -4;
private int pPrevProc, hWnd;
delegate int MyCallBack(int hWnd, int message, int wParam, int lParam);
[DllImport("User32.dll"

]
public static extern int SetWindowLong(int hWnd, int nIndex, int newLong);
[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern int CallWindowProc (int pPrevProc, int hWnd, int message,int wParam,int lParam);
public event MsgEventHandler OnMessage;
public HookMessage(int wHandle)
{
hWnd = wHandle;
MyCallBack wndProc= new MyCallBack(WindowProc);
pPrevProc = SetWindowLong(hWnd, GWL_WNDPROC, (int)wndProc);
}
~HookMessage()
{
SetWindowLong(hWnd, GWL_WNDPROC, pPrevProc);
}
public int WindowProc(int hWnd, int message, int wParam, int lParam)
{
//WindowProc = CallWindowProc(pPrevProc, hWnd, message, wParam, lParam);
MsgEventArgs args= new MsgEventArgs(hWnd,message,wParam,lParam);
this.OnMessage(this,args);
return CallWindowProc(pPrevProc, hWnd, message, wParam, lParam);
}
}
}
//*******************************************************//
The compile error is "D:\Temp\HookMessage.cs(50): Cannot convert type 'CSToolWinAddin.HookMessage.MyCallBack' to 'int'".
Thanks anyway.