Window move message WM_WINDOWPOSCHANGING = 0x46 C#

I

I_Need_Help

hi
I want to listen to WM_WINDOWPOSCHANGING from notepad so my application
knows when it is moved.

I can get the handle of notepad ok and if I use the handle from my form I
can get the messages but I can't hook the messages form notepad!

Help please!!!
code snippet:

string applicationName = "notepad";

Process[] proc = Process.GetProcessesByName(applicationName);

if (proc.Length!=0)

{

Process testProc = proc[0];

IntPtr hWnd = testProc.MainWindowHandle;

SubclassHWND s = new SubclassHWND();

//s.AssignHandle(hWnd); // does not hook the Windows app notepad!

s.AssignHandle(this.Handle); // gets messages for the form1 ok

}

private const int WM_WINDOWPOSCHANGING = 0x46;

protected override void WndProc(ref Message m)

{

// Perform whatever custom processing you must have for this message

if (m.Msg == WM_WINDOWPOSCHANGING)

{

System.Diagnostics.Debug.WriteLine(m.ToString());

}

// forward message to base WndProc

base.WndProc(ref m);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top