how to cast system.intptr to struct

Discussion in 'ASP .Net' started by BestNews, Sep 2, 2003.

  1. BestNews

    BestNews Guest

    Hi all,
    how to cast an System.IntPtr value to struct type.
    Example:
    protected override void WndProc(ref System.Windows.Forms.Message m)


    {

    const int WM_WINDOWPOSCHANGED = 0x0047;

    if(m.Msg == WM_WINDOWPOSCHANGED)


    {

    string str="";

    quickGetText(0,-1,ref str);

    //HERE I NEED TO CAST m.LParam to WINDOWPOS struct

    //WINDOWPOS wndptr = (WINDOWPOS)m.LParam;

    return;


    }

    base.WndProc(ref m);

    }

    //C++ structure declaration

    [StructLayout(LayoutKind.Sequential)]

    struct WINDOWPOS

    {

    System.IntPtr hwnd;

    System.IntPtr hwndInsertAfter;

    int x;

    int y;

    int cx;

    int cy;

    System.UInt32 flags;

    }

    Can any help me out.

    regards

    subash
    BestNews, Sep 2, 2003
    #1
    1. Advertising

  2. BestNews

    BestNews Guest

    Thanks a lot Mattias Sjögren
    "Mattias Sjögren" <> wrote in message
    news:...
    >
    > >//HERE I NEED TO CAST m.LParam to WINDOWPOS struct
    > >
    > >//WINDOWPOS wndptr = (WINDOWPOS)m.LParam;

    >
    > WINDOWPOS wndptr = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));
    >
    >
    >
    > Mattias
    >
    > --
    > Mattias Sjögren [MVP] mattias @ mvps.org
    > http://www.msjogren.net/dotnet/
    > Please reply only to the newsgroup.
    BestNews, Sep 3, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SGlmbmkgU2hhaHphcmQ=?=

    Invalid cast from System.Int32 to System.Byte[].

    =?Utf-8?B?SGlmbmkgU2hhaHphcmQ=?=, Feb 15, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,794
    William F. Robertson, Jr.
    Feb 15, 2005
  2. Chris Fogelklou
    Replies:
    36
    Views:
    1,373
    Chris Fogelklou
    Apr 20, 2004
  3. Replies:
    7
    Views:
    485
  4. Replies:
    1
    Views:
    762
    Bo Persson
    Aug 26, 2006
  5. Tien Pham via .NET 247

    problems with intptr indexing and marshaling data

    Tien Pham via .NET 247, Mar 30, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    151
    Tien Pham via .NET 247
    Mar 30, 2005
Loading...

Share This Page