PDA

View Full Version : How to use ScreenToClient



jeremyp
04-20-2001, 10:47 AM
I'm trying to convert a point with the ScreenToClient function. I don't know what the parameters are supposed to be. Any help would be greatly appreciated.

POINT mpos; // Mouse Position
POINT cur_mpos; // Temp Var for Testing

GetCursorPos(&mpos);
cur_mpos = ScreenToClient(hWnd, mpos);

error C2664: 'ScreenToClient' : cannot convert parameter 2 from 'struct tagPOINT' to 'struct tagPOINT *'

Deiussum
04-20-2001, 10:55 AM
ScreenToClient(hWnd, &mpos);

mpos will now have the converted coordinates. It returns TRUE or FALSE to tell you if it was successful or not, not the new position.



From MSDN:

BOOL ScreenToClient(
HWND hWnd,
LPPOINT lpPoint );



Don't take this the wrong way, but you really should concentrate on learning C/C++ and the Win32 API before trying to get too far into OpenGL. It'll help you out a lot in the long run. While you're at it, familiarize yourself with MSDN, it's an invaluable refrence. Simple questions like this really aren't OpenGL questions, but a lack of understanding of the language.

Michael Steinberg
04-20-2001, 10:56 AM
You should look more exatcly into the error message that got produced...

it has to be
cur_mpos = ScreenToClient(hWnd, &mpos);

Michael Steinberg
04-20-2001, 10:57 AM
That was double-post Deissum... http://www.opengl.org/discussion_boards/ubb/smile.gif

jeremyp
04-20-2001, 06:38 PM
I did look at the MSDN, but I must have missed the bool infront of ScreenToClient. That was my fault. Thank you for the correction. But I did need to know what I should have used for lpPoint. That clarifies a few things. Thanks.

Deiussum
04-22-2001, 02:37 PM
The LP on things is a Win32 naming convention meaning a "long pointer." Whenever you see something like LPPOINT, you should think POINT*. Learn Win32 a bit better and you'll start to understand the naming conventions.