例: メッセージ構造体

提供: RAD Studio
移動先: 案内検索

独自のメッセージの定義 への移動


たとえば、すべてのマウス メッセージに対応するメッセージ レコード TWMMouse では、バリアント レコードを使用して、同じパラメータの名前を 2 組定義しています。

TWMMouse = record
   Msg: Cardinal;
   MsgFiller: TDWordFiller; ( first is the message ID )
   Keys: Longint;       ( this is the wParam )
   KeysFiller: TDWordFiller; 
   case Integer of   ( two ways to look at the lParam )
     0: (
       XPos: Smallint;    ( either as x- and y-coordinates...)
       YPos: Smallint;
       XYPosFiller: TDWordFiller;);
     1: (
       Pos: TSmallPoint;   ( ... or as a single point )
       PosFiller: TDWordFiller;
       Result: LRESULT);   ( and finally, the result field )
 end;
TWMKey = record
   Msg: Cardinal; // first parameter is the message ID
   MsgFiller: TDWordFiller; // this is the first wParam
   CharCode: Word;
   Unused: Word;
   CharCodeUnusedFiller: TDWordFiller;
   KeyData: Longint;   // this is the lParam
   KeyDataFiller: TDWordFiller;
   Result: LRESULT;   // this is the result data member
 end;

関連項目