Thread: SetCursorPos() arguments don't exept POINT vars?

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Question SetCursorPos() arguments don't exept POINT vars?

    It reads the mouse pos and yet when I use ptMouseNew in SetCursorPos(), it doesn't work. Why not? My only guess is that the var POINT and the var int may not be compadable. All though my Compiler (Dev-C++) doesn't catch any errors.


    Code:
    	ptMouseNew.x = GET_X_LPARAM(lParam); 
    	ptMouseNew.y = GET_Y_LPARAM(lParam); 
    	SetCursorPos(ptMouseNew.x, ptMouseNew.y);

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    What message are you handling?

    SetCursorPos takes screen coordinates, are you sure you want this?

  3. #3
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Yes I do, I also want it to read the cursors pos acording to the screen coordinates.

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Doing this on Windows NT/2000/XP?
    MSDN says:
    "The calling process must have WINSTA_WRITEATTRIBUTES access to the window station."

    You'll need GetProcessWindowStation and OpenWindowStation if that's the problem.

    Security, eh?

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I use something like......

    Code:
    POINTS   ptsMouse;//two short ints
    POINT     ptScreen;//two ints
    
    //get mouse coods relative to client 
    ptsMouse=MAKEPOINTS(lParam);
    //convert to a POINT
    POINTSTOPOINT(ptScreen,ptsMouse);
    //convert to Screen coods
    ClientToScreen(hWnd,ptScreen);
    //move the mouse
    SetCursorPos(ptScreen.x,ptScreen.y);
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Okay, I figured it out.


    Code:
            GetCursorPos(&pt); 
            ScreenToClient(hwnd, &pt);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. observing whether a point is in a triangle???
    By hebele in forum C++ Programming
    Replies: 1
    Last Post: 05-19-2003, 03:38 PM
  2. fixed point / floating point
    By confuted in forum Game Programming
    Replies: 4
    Last Post: 08-13-2002, 01:25 PM
  3. point lies in circle?
    By cozman in forum Game Programming
    Replies: 3
    Last Post: 12-20-2001, 04:39 PM
  4. more with my 1st structure program
    By sballew in forum C Programming
    Replies: 42
    Last Post: 10-22-2001, 08:03 PM