Shoutbox

[?] Getting the exact window position? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [?] Getting the exact window position? (/showthread.php?tid=69868)

[?] Getting the exact window position? by effection on 12-24-2006 at 05:07 PM

I know that GetWindowRect gets the size of the window relevant to the top left corner of the window but is there anyway to get the position of the window relevant to the top left corner of the full screen?


RE: [?] Getting the exact window position? by Mnjul on 12-24-2006 at 06:16 PM

I think you need GetWindowPos :)


RE: [?] Getting the exact window position? by CookieRevised on 12-24-2006 at 06:28 PM

quote:
Originally posted by effection
I know that GetWindowRect gets the size of the window relevant to the top left corner of the window but is there anyway to get the position of the window relevant to the top left corner of the full screen?
You got your info a bit wrong there, and as such you actually answered your own question ;)

It is GetWindowRect which you need to use. Coordinates are given in screen coordinates that are relative to the upper-left corner of the screen.

This means you can know the position of the window relative to the screen as well as it size by either taking the coordinates in its 16 byte long RECT structure as-is, or by doing right - left and top - bottom.

quote:
Originally posted by Mnjul
I think you need GetWindowPos :)

SetWindowPos exists, but not GetWindowPos


------------------------------------------------------------

So you need to use either:
GetWindowRect
GetWindowRgn (if window is not rectangular)
GetWindowInfo (if you also need other info at the same time)

all defined in User32.dll


;)
RE: [?] Getting the exact window position? by effection on 12-24-2006 at 08:45 PM

ah right i see im stupid i didnt look at the code right!
i seen

code:
Interop.Call("User32", "GetWindowRect", Handle * 1, RECT);

var CurWidth = RECT.ReadDWORD(8) - RECT.ReadDWORD(0);

and didn't realise that it was getting the coords then from that working out the width *hits head*