By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,813 Members | 2,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,813 IT Pros & Developers. It's quick & easy.

how to cast IntPtr to struct type

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
System.Runtime.InteropServices.Marshal.PtrToStruct ure
Nathan Smith | Solution Developer
Avanade Inc | West Region
Mobile: 602-502-3606
Messenger: na************@hotmail.com
www.avanade.com
"BestNews" <su********@yahoo.com> wrote in message news:<3f*********************@read-nat.news.nl.uu.net>...
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

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.