RAD Studio |  |

Example: Message Structure

For example, here is the message record for all mouse messages, TWMMouse, which uses a variant record to define two sets of names for the same parameters.

Copy Code

    type
      TWMMouse = record
        Msg: TMsgParam;        ( first is the message ID )
        Keys: Word;            ( this is the wParam )
        case Integer of        ( two ways to look at the lParam )
          0: {
             XPos: Integer;    ( either as x- and y-coordinates...)
             YPos: Integer);
          1: {
             Pos: TPoint;      ( ... or as a single point )
             Result: Longint); ( and finally, the result field )
    end;

Copy Code

    struct TWMKey
    {
      Cardinal Msg;                      // first parameter is the message ID
      Word CharCode;                     // this is the first wParam
      Word Unused;
      Longint KeyData;                   // this is the lParam
      Longint Result;                    // this is the result data member
    };

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!