Archived

This topic is now archived and is closed to further replies.

Daaark

Mouse Coordinates?

Recommended Posts

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);
  

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites