Accessing To A Struct With A Given Pointer

Discussion in 'MFC' started by AhmedHan, Oct 11, 2005.

  1. AhmedHan

    AhmedHan New Member

    Joined:
    Oct 11, 2005
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.stirve.com
    We have a struct defined as :


    Then we are sent a message...

    And this is the code which gets the message




    lParam contains the address of the struct. Here we want to access to the struct.

    But there is a problem with the code. pWinPos is a constant pointer, so we can't simply assign an address to it.

    So, finally, here is my question...
    How can I access to the WINDOWPOS struct whose address is given by lParam

    PS : I am using Dev-C++
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,341
    Likes Received:
    378
    Trophy Points:
    83
    Welcome to the Programming forum.
    By type casting the lParam pointer to the WINDOWPOS pointer.

    pWinPos = (WINDOWPOS *)lParam;

    Thanks
    Shabbir Bhimani
     
  3. AhmedHan

    AhmedHan New Member

    Joined:
    Oct 11, 2005
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.stirve.com
    That one works, thank you.

    Actually, I tried the same thing, but I put the * oparetor to the wrong place :
    pWinPos = (* WINDOWPOS)lParam; instead of pWinPos = (WINDOWPOS *)lParam;
    That is silly of me :)
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,341
    Likes Received:
    378
    Trophy Points:
    83
    The silly's can come at any time and if you share the knowledge and queries with other you tend to reduce them. haha
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice