Hi, i'm trying to make an overlay for a game that will go on the top right of the game's window.
ive been researching possible ways to do this, and it seems the only way to get an external windows location is by using GetWindowRect(), so I tried that and its giving me the wrong output.
In my code I created a new process (chrome), and tried it on that, and I had a messagebox print the "rect.Top" and the "rect.Right" values of my chrome process. Every time I got random numbers that werent at all where chrome was.
How can I get this to work? or is there another way I can make my form "latch" on to another window in the top right of it?
[DllImport("user32.dll", SetLastError = true)]
static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
private struct RECT
public int Left;
public int Top;
public int Right;
public int Bottom;
Process chrome = new Process();
rotmg.StartInfo.FileName = "chrome.exe";
IntPtr hWnd = chrome.Handle;
RECT rct = new RECT();
GetWindowRect(hWnd, ref rct);
MessageBox.Show(rct.Top + ", " + rct.Right);
1 Replies - 193 Views - Last Post: 02 February 2013 - 04:28 PM
Replies To: Latching my form to the top right of an external process
Page 1 of 1