relative coordinates to absolute?
-
hiho@ll i'm using OnLButtonUp to get the coordinates of a mouseclick the problem: OnLButtonUp from MSDN: Specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window so i thought using GetWindowRect and just adding the values point.x+=rect.left AND point.y+=rect.top will convert the relative coordinates to absolute the problem is for example if my window is in the middle of the screen and i click on the top of the screen (the absolute y position should be between 0 or 10) i get an relative point.y coordinate -22!!!! which means i clicked 22 pixel above my window? but i clicked a few hundred pixels above my window! so how can i convert the relative coordinates to absolute?
-
hiho@ll i'm using OnLButtonUp to get the coordinates of a mouseclick the problem: OnLButtonUp from MSDN: Specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window so i thought using GetWindowRect and just adding the values point.x+=rect.left AND point.y+=rect.top will convert the relative coordinates to absolute the problem is for example if my window is in the middle of the screen and i click on the top of the screen (the absolute y position should be between 0 or 10) i get an relative point.y coordinate -22!!!! which means i clicked 22 pixel above my window? but i clicked a few hundred pixels above my window! so how can i convert the relative coordinates to absolute?
-
hiho@ll i'm using OnLButtonUp to get the coordinates of a mouseclick the problem: OnLButtonUp from MSDN: Specifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window so i thought using GetWindowRect and just adding the values point.x+=rect.left AND point.y+=rect.top will convert the relative coordinates to absolute the problem is for example if my window is in the middle of the screen and i click on the top of the screen (the absolute y position should be between 0 or 10) i get an relative point.y coordinate -22!!!! which means i clicked 22 pixel above my window? but i clicked a few hundred pixels above my window! so how can i convert the relative coordinates to absolute?
ThinkingPrometheus wrote: so how can i convert the relative coordinates to absolute? Use Api
ScreenToClient()
andClientToScreen()
, for more info consult MSDN."Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
I think you need to be using ClientToScreen. For example:
// point is relative to your window. CPoint ptScreen = point; ClientToScreen (&ptScreen); // ptScreen now holds the value as screen co-ords
Hope that helps, 'bod.great it worked! thx