Thread: Tracking the mouse

  1. #1
    ‡ †hë Ö†hÈr sîÐè ‡ Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299

    Tracking the mouse

    I know there is a way to track the mouse but have know idea about where to find it. I've seen a copple of UnClear examples but nothing showes where/how to get the x,y coordinants couser.
    i know it is a little more than just that but all i need is a push in the right direction(or a function/method name) thx.
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Handle WM_MOUSEMOVE msg or you can use GetCursorPos:

    POINT WhatsThePoint;
    GetCusorPos(&WhatsThePoint);

    I think that the MSG structure used in message handling also contains cursor coords at time (which is also available) of each msg.

    Hope that helps.

  3. #3
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey heres some code


    Code:
    case WM_MOUSEMOVE:
    {
    int x, y;
    
    x = LOWORD(lParam);  
    y = HIWORD(lParam); 
    }
    You now have the x, y cords in two ints

    Cheers
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  4. #4
    ‡ †hë Ö†hÈr sîÐè ‡ Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299
    Thx.
    that is what i needed
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  5. #5
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Exclamation An easyer way that doesn't require having a window...

    This will: Not require a window, and be relative to the SCREEN! hehe

    POINT mpos = {0,0};
    GetCursorPos(&mpos);

    then you can refrence is just "mpos.x" and "mpos.y".

    Tada! hehe

    SPH

  6. #6
    Unregistered
    Guest
    Also another way in WM_LBUTTONDOWN ect

    Code:
    case WM_LBUTTONDOWN:
    //get the mouse cood as a POINT (int x , y)
    POINTSTOPOINT(ptBegin,MAKEPOINTS(lParam));
    ClientToScreen(hWnd,&ptBegin);//convert to screen coods if needed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need Help in Mouse Pointer
    By obaid in forum C++ Programming
    Replies: 3
    Last Post: 12-07-2006, 03:33 AM
  2. Problem in mouse position
    By Arangol in forum Game Programming
    Replies: 6
    Last Post: 08-08-2006, 07:07 AM
  3. Making a mouse hover button, API style
    By hanhao in forum C++ Programming
    Replies: 1
    Last Post: 05-27-2004, 06:17 AM
  4. tracking mouse movements
    By werdy666 in forum Windows Programming
    Replies: 4
    Last Post: 10-19-2002, 12:16 PM
  5. Game Design Topic #2 - Keyboard or Mouse?
    By TechWins in forum Game Programming
    Replies: 4
    Last Post: 10-08-2002, 03:34 PM