PC Review


Reply
Thread Tools Rate Thread

How to define own message struct?

 
 
Rainer Queck
Guest
Posts: n/a
 
      21st Feb 2007
Hello NG,

in forme times (decades ago :-) I used to definy my own message structs in
Delphi like this :

TGbReportMessage = packed record
Msg: Cardinal;
Action : Word;
ActionId: Word;
Handle : UINT;
Result: LongInt;
end;

Can I do the same in C# and if yes how?

Thanks for Help
Rainer Queck


 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      21st Feb 2007
Hi,

"Rainer Queck" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello NG,
>
> in forme times (decades ago :-) I used to definy my own message structs in
> Delphi like this :
>
> TGbReportMessage = packed record
> Msg: Cardinal;
> Action : Word;
> ActionId: Word;
> Handle : UINT;
> Result: LongInt;
> end;
>
> Can I do the same in C# and if yes how?


You can use a struct for this.


 
Reply With Quote
 
Rainer Queck
Guest
Posts: n/a
 
      21st Feb 2007
Hi Ignacio,

> You can use a struct for this.

Thanks for responding.

Yes, but can I then typcast a incoming windows message to this struct like I
used to do this in Delphi?

// make sure we process only our messages ....
if aMsg.Msg=FMsgId then
begin
FCurrentMsg := TGbReportMessage(aMsg);

Regards
Rainer


 
Reply With Quote
 
Peter Bradley
Guest
Posts: n/a
 
      21st Feb 2007
Depends what its type was before you tried to cast it.


Peter

"Rainer Queck" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Ignacio,
>
>> You can use a struct for this.

> Thanks for responding.
>
> Yes, but can I then typcast a incoming windows message to this struct like
> I used to do this in Delphi?
>
> // make sure we process only our messages ....
> if aMsg.Msg=FMsgId then
> begin
> FCurrentMsg := TGbReportMessage(aMsg);
>
> Regards
> Rainer
>



 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      21st Feb 2007
Hi,

"Rainer Queck" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Ignacio,
>
>> You can use a struct for this.

> Thanks for responding.
>
> Yes, but can I then typcast a incoming windows message to this struct like
> I used to do this in Delphi?
>
> // make sure we process only our messages ....
> if aMsg.Msg=FMsgId then
> begin
> FCurrentMsg := TGbReportMessage(aMsg);


In general no, it depends of the type it was before. You could do something
similar to Delphi if you use an unsafe block.


--
Ignacio Machin
machin AT laceupsolutions com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to define struct with array in C#? Polaris Microsoft C# .NET 2 13th Mar 2008 12:22 PM
Define custom struct and populate stuie_norris@yahoo.com.au Microsoft C# .NET 3 3rd Apr 2007 12:02 PM
Define Struct =?Utf-8?B?W1lvc2ld?= Microsoft C# .NET 1 20th Jun 2004 04:09 PM
how to use "indexof" with an user define struct array Herve MAILLARD Microsoft C# .NET 1 7th Aug 2003 06:11 PM
How to define a struct used in ATL.NET interface? Dejun Yang Microsoft Dot NET Framework 0 10th Jul 2003 11:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:59 PM.