I am going to be checking if the user is moving any window around (my application does not have an interface) and respond accordingly. What do you think is the best way to do this? Can I determine if the user is clicking on a titlebar? Can I determine if a window is being moved? I then need to grab the hWnd of the window after I know it's being moved.
+2
A:
here is a technique to spy on window handles. You can inspect all the handles which are open and wait for the move messages.
EDIT
Andrew Keith
2009-11-21 23:29:32
That's a slick tool I used it once. The project was DOA, but who was I to pass up the opportunity to learn about spying on apps. :-)
Jason D
2009-11-25 04:49:44
+1
A:
To get notifications for all windows, not just Windows Forms ones, you'll need to use a hook set by the SetWindowsHookEx() API function. You'll need a WH_CALLWNDPROC
hook so you can see the WM_MOVE message that Windows sends to the window.
Unfortunately, that's a global hook. The code that implements the hook callback needs to be packaged into a DLL so that it can be injected into all target processes. That shoots a hole into your plans to use C# for this, you can't inject the CLR. The DLL must be written in unmanaged code.
This code project offers an approach, including the unmanaged injectable DLL you'll need.
Hans Passant
2009-11-25 18:28:38