Can anyone tell me were I am making mistake in the snippet
Posted
by Solitaire
on Stack Overflow
See other posts from Stack Overflow
or by Solitaire
Published on 2009-09-23T13:05:03Z
Indexed on
2010/05/18
3:21 UTC
Read the original article
Hit count: 185
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...
© Stack Overflow or respective owner