LPPOINT problem

This is a discussion on LPPOINT problem within the Game Programming forums, part of the General Programming Boards category; i'm using GetCursorPos(LPPOINT lpPoint) to well... get the cursor position. I can't figure out how to incorperate an lpPoint to ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    27

    LPPOINT problem

    i'm using GetCursorPos(LPPOINT lpPoint) to well... get the cursor position. I can't figure out how to incorperate an lpPoint to be mildly helpful to me. Anyone be of help on this? If i can't use those in equations and such to compare them and find angles, what is there use? I'm looking for a way to capture a couple of numbers that I can plug into my equations (willing to modify) so I can calculate what I need to to get my camera finished. This is the LAST step, but it is VERY difficult to find good info on capturing mouse (being cursor) coordinates, and the only info I found so far, Has brought me to my LPPOINT problems.

    I'm sure that having float in my struct isn't helpful, but I get way more conversion errors

    Code:
    struct cursorPosition
    {
    	float x;
    	float y;
    };
    or...

    Code:
    struct cursorPosition
    {
    	LPPOINT x;
    	LPPOINT y;
    };
    this is the code, if you need a structure to see why I need the coordinates, otherwise, all the juicy calculations are left out due to irrelevency, seeing as I don't even know if it'll work yet. The problem is currently compiling. (This runs every frame mind you. I don't mean to state the obvious if I have done so, but just making sure)
    Code:
    if (GetAsyncKeyState(VK_RBUTTON)&0x8000)
    		{
    			if (cursorSet == false)
    			{
    				//retrieve coordinates of where right mouse button started being pressed
                                    cursorSet = true;
    			}
    			else
    			{
    				//retrieve current coordinates
    				
    				//zero out coordinates for comparison
    				
    				//Get angle of movement
    		
                                    //calulate movement
    
    			}
    		}
    
    else
    {
          cursorSet = false;
    }
    Any info will be appreciated, even if it is just commenting on algorithm problems.
    Last edited by blurrymadness; 04-29-2007 at 06:21 PM. Reason: code readability/spelling errors

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    It seems to me you're struggling with some of Microsoft's pointer typedef's. 'LP' means 'long pointer' ie LPPOINT is just a pointer to a POINT struct, POINT* - as described in the msdn GetCursorPos description. So declare a POINT and pass the address of that variable to GetCursorPos:
    Code:
    POINT cursor_pos;
    GetCursorPos(&cursor_pos);
    Note that GetCursorPos provides cursor position in screen coordinates - provided your window covers the whole screen this is not an issue but if it doesn't, you'll probably want to convert them (see ScreenToClient).

    Other methods of getting cursor position that might be of interest include handling the WM_MOUSEMOVE message or just getting them directly from the MSG struct from your message loop. Since you seem to be interested in cursor position when the right mouse button is clicked, handling the WM_RBUTTONDOWN message would provide you with all you need without having to use either GetAsyncKeyState or GetCursorPos.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    27

    Thanks!

    I haven't tried the info yet, but that all makes sense. I think i'll stick with getcursorpos() and getasynckeystate() because it's not only the event of pressing the right button, but holding it is actually what I'M after, thanks again!

    Erich

    (i'll post again if I still have problems)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21