473,566 Members | 3,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to cast IntPtr to struct type

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_WINDOWPOSCHA NGED = 0x0047;

if(m.Msg == WM_WINDOWPOSCHA NGED)
{

string str="";

quickGetText(0,-1,ref str);

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

//WINDOWPOS wndptr = (WINDOWPOS)m.LP aram;

return;
}

base.WndProc(re f m);

}

//C++ structure declaration

[StructLayout(La youtKind.Sequen tial)]

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
1 6088
System.Runtime. InteropServices .Marshal.PtrToS tructure
Nathan Smith | Solution Developer
Avanade Inc | West Region
Mobile: 602-502-3606
Messenger: na************@ hotmail.com
www.avanade.com
"BestNews" <su********@yah oo.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_WINDOWPOSCHA NGED = 0x0047;

if(m.Msg == WM_WINDOWPOSCHA NGED)
{

string str="";

quickGetText(0,-1,ref str);

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

//WINDOWPOS wndptr = (WINDOWPOS)m.LP aram;

return;
}

base.WndProc(re f m);

}

//C++ structure declaration

[StructLayout(La youtKind.Sequen tial)]

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2034
by: Alberto Giménez | last post by:
Hi, I've seen some object oriented programming bits out there and i'm not sure if they're legal. For example: struct Object { int field1; int field2; }; struct SubObject { int field1; /* the same as Object */
3
14483
by: Pablo Gutierrez | last post by:
I have a C# method that reads Binary data (BLOB type) from a database and returns the data an array of bytes (i.e byte outbyte = new byte;). The BLOB column is saved into the database by a C program (UNIX) as an array of "struct point" where struct point //C structure { int Time; //32 bits
28
3009
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
1
1830
by: BestNews | last post by:
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;
2
1443
by: Peter Larsen | last post by:
Hi, How do i type cast a type to an array of type, e.g. IntPtr to IntPtr ?? /Peter
6
527
by: Jack | last post by:
Is it possible to cast a 4-byte data type (e.g. an unsigned int) to a 4-byte struct? Sometimes the HIWORD and LOWORD of a 4-byte value contain information independent of each other. Is there a direct way to perform this cast? If not, is there way in C++ to do it? For example, I would like my function test() to work the way it is coded...
27
3157
by: Eric | last post by:
Hi all, I have a C++ application that load C# applets. A method use an IntPtr parameter because I want to be 32/64-bit compatible. The problem is in the .tlh file generated. This parameter is a long and not an INT_PTR and I don't know why ? Here is some code that may help you. In C# project.
7
3942
by: * Tong * | last post by:
Hi, I couldn't figure out how to properly type cast in this case: $ cat -n type_cast.c 1 #include <stdio.h> 2 3 typedef unsigned char Byte; 4 typedef signed char Small_Int; 5
0
2114
by: Charming12 | last post by:
Hi All, I have a strange problem and due to my inefficiency with IntPtr i am unable to figure it out. I have an structure something like: public struct Detail { public int age; public Detail(int _age)
0
7673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.