My apologies for taking so long to reply. I have managed to whip up some code that gathers a list of all running processes and allows me to get rectangle data for the active window. There are a few issues, for example the X and Y loations are correct, but since I have multiple monitors, for some reason my width and height are being displayed wrong. Each monitor is 1920x1200. I've got a window open that is 1696x1056, located at 2032x94, so my rectangle should be:
{X=2032, Y=94, Width=1696, Height=1056}
Intead it s returned as:
{X=2032, Y=94, Width=3728, Height=1150}
However, it seems to be as simple as subtracting the X from the Width and the Y from the Height to get the actual size of the window, so all I'd have to do is:
- Rectangle rect = new Rectangle();
-
GetWindowRect(hWnd, ref rect);
-
rect.Width -= rect.X;
-
rect.Height -= rect.Y;
And I'll have the correct coordinates and size of an external window.
Now I just have to figure out how to detect when I put MY program window over the external one. Hmmm...
I'm finishing up a screenshot program that I wrote that allows the user to position a rectangle anywhere on the screen, size it however they want, then push a button to take a screenshot of that portion of the screen. It started off as a test of my abilities, but it's grown up quite a bit. What I want to do with what I just learned is allow the user to drag the screenshot rectangle over an external window and allow them to lock the rectangle to that window. Armed with this new knowledge, I think I can do it.