Can anyone tell me were I am making mistake in the snippet
- by Solitaire
public partial class Form1 : Form
{
[DllImport("coredll.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
const int GWL_WNDPROC = -4;
public delegate int WindProc(IntPtr hWnd, uint msg, long Wparam, long lparam);
public Form1()
{
InitializeComponent();
WindProc SampleProc = new WindProc (SubclassWndProc);
SetWindowLong(this .Handle , GWL_WNDPROC,
SampleProc.Method .MethodHandle.Value.ToInt32());
}
public int SubclassWndProc(IntPtr hwnd, uint msg, long Wparam, long lparam)
{
return 1;
}
Here is the sample which i was trying to take the window procedure of a form, this is how i do in C++ i get the windwproc easlily if i try the same in C# .net 3.5 i am unable to get the window proc,, after calling SetWindowLong API application hangs and it pops up some dont send report... i have read this is the way to get the window proc.. please let me know were i am making mistake...