Created
October 3, 2012 21:23
-
-
Save maul-esel/3829941 to your computer and use it in GitHub Desktop.
a function to convert client-area-relative cooordinates to window-relative coordinates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ClientToWindow(hwnd, byRef x, byRef y) | |
{ | |
VarSetCapacity(pt, 8, 0) | |
, NumPut(x, pt, 0, "UInt") | |
, NumPut(y, pt, 4, "UInt") | |
if (!DllCall("ClientToScreen", "Ptr", hwnd, "Ptr", &pt, "UInt")) | |
return false | |
VarSetCapacity(rc, 16, 0) | |
if (!DllCall("GetWindowRect", "Ptr", hwnd, "Ptr", &rc, "UInt")) | |
return false | |
screen_x := NumGet(pt, 0, "UInt") | |
, screen_y := NumGet(pt, 4, "UInt") | |
win_x := NumGet(rc, 0, "UInt") | |
, win_y := NumGet(rc, 4, "UInt") | |
x := screen_x - win_x | |
, y := screen_y - win_y | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment