How to define own message struct?

  • Thread starter Thread starter Rainer Queck
  • Start date Start date
R

Rainer Queck

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
 
Hi,

Rainer Queck said:
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.
 
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
 
Hi,

Rainer Queck said:
Hi Ignacio,

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.
 
Back
Top