Menu

Getting mouse position (x/y) to vars.

2002-12-09
2012-09-26
  • Nobody/Anonymous

    Inside a case WM_RBUTTONUP, how do i set to variables the exact position of the mouse cursor when the button is released?
    Will the cordinates be the same on any windows resolution?

     
    • Derek Baker

      Derek Baker - 2002-12-09

      x = LOWORD(lParam));
      y = HIWORD(lParam));

      Depands on what you mean by same: 400 pixels from the left side is 400 regardless of resolution.

      But obviously pixels on a screen vary in postion based upon resolution.

      You could use a real world based co-ordinate system; I guess that would allow you to keep positions on the screen the same regardless of resolution.

      Derek

                     

       
    • Nobody/Anonymous

      GetCursorPosition();

      Kip

       
      • Nobody/Anonymous

        Key Kip, that what im using. Im getting x/y position with GetCursorPosition to a Point sctructure. I was wondering for example how could i set that values in order for my app to start centralized in any screen resolution

         
    • Nobody/Anonymous

      // Create window...
      hwnd = CreateWindowEx(WS_EX_0, g_szAppName, g_szAppName, WS_OVERLAPPED | WS_SYSMENU, (GetSystemMetrics(SM_CXSCREEN) - VUPDATE_WIDTH)/2, (GetSystemMetrics(SM_CYSCREEN)-VUPDATE_HEIGHT)/2, VUPDATE_WIDTH, VUPDATE_HEIGHT, NULL, NULL, hInstance, NULL);

      =)

      Kip

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.