Results 1 to 6 of 6

Thread: mousepos

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    mousepos

    When I call this function when a button is pressed it freezes. Will this get the mouse coordinates like it is intended to do?

    Code:
    void getmousepos()
    {
    POINT p;
    for(;;)
    GetCursorPos(&p);
    SendMessage(editbxX, WM_SETTEXT,0,(LPARAM) p.x);
    SendMessage(editbxY, WM_SETTEXT,0,(LPARAM) p.y);
    
    
    }
    Matt

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    What you are doing might work, but there is an easier way if you are catching the mouse events. The HI and LO of the lParam is the x and the y of the mouse. So for example:

    PHP Code:
    case WM_LBUTTONDOWN:
        
    SendMessage(editbxXWM_SETTEXT,0,LOWORD(lParam));   //X Pos
        
    SendMessage(editbxXWM_SETTEXT,0,HIWORD(lParam));  //Y Pos
        
    break; 
    Last edited by Technocrat; Jul 17th, 2001 at 11:55 AM.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    I can't seem to get anything to work.What would you do if you wanted to get the mouse position after it moves? What functions would you use? Thanks
    Matt

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Can you give me a better example of what you want.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330
    I wanted it so that when you move the mouse the coordinates are updated in the 2 editboxes. I got everything to work finally. I just used the WM_MOUSEMOVE to have it update them. Thanks anyway
    Matt

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Incidentally the reason it froze with your first code is because you were in an infinite loop and it was blocking any more messages from arriving (DispatchMessage won't return until the event handler has).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width