views:

21

answers:

1

Hi,

Working with OpenGL, I used

CreateWindow( 
"app", "App Window", 
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
0, 0, 1024, 768,
NULL, NULL, hInstance, this );

to create a window and now I need to find the mouse position over the client (render) area. However, I noticed that the mouse coordinates extends all the way into the title/caption bar and this will give a wrong mouse-to-screen-to-world coordinate. I could find the fixed offset by trial and error, but is there a proper flag/trick to get the client mouse coord?

Thanks!

+2  A: 

use GetCursorPos http://msdn.microsoft.com/en-us/library/ms648390%28VS.85%29.aspx to get the mouse position and then convert it to client-space using GetClientRect msdn.microsoft.com/en-us/library/ms633503%28VS.85%29.aspx (cant post >1 urls atm)

fusi
oops! apologies - i meant ScreenToClient (http://msdn.microsoft.com/en-us/library/dd162952%28VS.85%29.aspx), rather than GetClientRect
fusi
Correct answer, let's get you some rep. +1 is all I can do.
Hans Passant
Thanks! I will try that.
Jake