Groups | Blog | Home
all groups > dotnet general > september 2003 >

dotnet general : how to cast IntPtr to struct type


nathans NO[at]SPAM avanade.com
9/2/2003 10:23:56 AM
System.Runtime.InteropServices.Marshal.PtrToStructure


Nathan Smith | Solution Developer
Avanade Inc | West Region
Mobile: 602-502-3606
Messenger: nathan_y_smith@hotmail.com
www.avanade.com


[quoted text, click to view]
BestNews
9/2/2003 6:28:00 PM
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

AddThis Social Bookmark Button