0

I have an application A, and I want it to stick to application B's window.

I want the relative window position of A to B to be fixed, so whenever B moves, A comes along.

I know the process name of application B. How do I get the window position, and the window position change event, of B?

I have the source of A but B is not available.

aihenry2980
  • 329
  • 2
  • 7
  • 18
  • Do you have the source to both, only one or perhaps neither? – kenny Dec 17 '13 at 01:16
  • The functionality you looking for is to my knowledge not part of .NET and you will need to P/Invoke WINAPI functions (or write a C++/CLI assembly with the required native code). WINAPI functions of interest: [FindWindow](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499.aspx), [GetWindowRect](http://msdn.microsoft.com/en-us/library/ms633519.aspx) (see comments there regarding Aero), [SetWindowsHookEx](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990.aspx) (you want the WH_GETMESSAGE hook, and checking for WM_MOVE, WM_WINDOWPOSCHANGED and WM_SIZE messages). –  Dec 17 '13 at 01:22
  • To get some inspiration about how to use the WINAPI functions i mentioned in my previous comment you might look at the following SO questions/answers: ["How to get and set window position of another application in c#"](http://stackoverflow.com/questions/1364440/how-to-get-and-set-window-position-of-another-application-in-c-sharp), ["c++ hooking to a different application, how to find thread id from process id?"](http://stackoverflow.com/questions/5922248/c-hooking-to-a-different-application-how-to-find-thread-id-from-process-id) –  Dec 17 '13 at 01:23

0 Answers0