Skip to main content
gamedev.net
🔒 Locked

Mouse Coordinates?

Started by Daaark Jan 19, 2003 at 1:14 AM 0 replies 300+ views
Original Post
Daaark
Daaark
How do you guys find the mouse cursor position in your opengl windows?
  
    HWND    Hwnd;
    POINT   Cursor;
    RECT    Rect;
    int     x,y;
    int     mx,my;    
    char    mouse[10];
        
    GetCursorPos(&Cursor);
    Hwnd = GetForegroundWindow();
    GetClientRect(Hwnd,&Rect);

    mx = (int)Cursor.x - (int)Rect.left;
    my = (int)Cursor.y - (int)Rect.top;

    sprintf(mouse,"%d,%d",mx,my);
    MessageBox(NULL,mouse,APPNAME,MB_OK);
  
Structural
Structural
I''m not sure if this is a problem only I had, but I think getClientRect doesn''t return a left and top property. Only a right and bottom one, that represent the height and width. I used getWindowRect to retrieve the left and top coordinates, and getclientrect to get the width and height of my client window.
STOP THE PLANET!! I WANT TO GET OFF!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.