windows api question: convert global screen coord to local client-area coord ?
by Orion Elenzil · in Technical Issues · 03/16/2009 (10:51 am) · 1 replies
howdy,
i've got a general windows API question.
i'm using the IDropTarget interface for drag-and-drop functionality, which sends events to the app with a pixel coordinate representing where the mouse cursor is.
however, the coordinates seem to be in global screen-space, ie [0,0] is the absolute top-left pixel of the entire monitor. what i want is for them to be relative to the "client space" of the window, so that [0,0] is the top-left of the torque canvas.
i can use GetWindowRect() to get the top-left corner of the window, but that includes the window border and title-bar etc, which are of variable size.
GetClientRect() does return the size of the client area, but not its location, unfortunately. anyone know the trick ?

i've got a general windows API question.
i'm using the IDropTarget interface for drag-and-drop functionality, which sends events to the app with a pixel coordinate representing where the mouse cursor is.
however, the coordinates seem to be in global screen-space, ie [0,0] is the absolute top-left pixel of the entire monitor. what i want is for them to be relative to the "client space" of the window, so that [0,0] is the top-left of the torque canvas.
i can use GetWindowRect() to get the top-left corner of the window, but that includes the window border and title-bar etc, which are of variable size.
GetClientRect() does return the size of the client area, but not its location, unfortunately. anyone know the trick ?
About the author
Associate Orion Elenzil
Real Life Plus
ScreenToClient() looks like the ticket.