Results 1 to 5 of 5

Thread: pointers..?

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    pointers..?

    is there a better way for me to initialize retPoint in the code below? My original code did not have two point structs but it crashed do to a null refreance when it ran. Why?

    Code:
    		void CursorPos(System::Drawing::Point *lpPoint){
    			POINT iPoint;
    			LPPOINT retPoint = &iPoint;
    			GetCursorPos(retPoint);
    			lpPoint->X=retPoint->x;
    			lpPoint->Y=retPoint->y;
    		}
    Magiaus

    If I helped give me some points.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169

    Re: pointers..?

    Originally posted by Magiaus
    is there a better way for me to initialize retPoint in the code below? My original code did not have two point structs but it crashed do to a null refreance when it ran. Why?

    Code:
    		void CursorPos(System::Drawing::Point *lpPoint){
    			POINT iPoint;
    			GetCursorPos(&iPoint);
    			lpPoint->X = iPoint->x;
    			lpPoint->Y = iPoint->y;
    		}
    See the changes. retPoint is only a pointer anyway, not a full struct, and you don't need it.
    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

  3. #3

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    I should have thought of that....

    thanks
    Magiaus

    If I helped give me some points.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    And the last two lines are invalid too (now that lpPoint is gone) and should be removed.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    I get what you mean bu the last two are still right because i am superclassing the GetCursorPos API for use in vb.net or C# and it passes the equiv type out I am going to chang it to a return though i think
    Magiaus

    If I helped give me some points.

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