How to define own message struct?

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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.
 
R

Rainer Queck

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top