TMessage is not TMsg!

TMessage is defined in Unit Messages and should not be mixed up with TMsg (Windows.pas) in the following case:

  WM_TEST = WM_USER + 1;

  TForm1 = class(TForm)
    procedure XY(var Msg : TMessage); message WM_TEST;

  SendMessage(Form1.Handle, WM_TEST, 1,2);

You should abandon all tutorials which use TMsg. You’ll get strange results. TMessage is for VCL and TMsg is for nonVCL programming.


I was told that there is an exception.
TApplication.OnMessage is defined as follow:

TMessageEvent = procedure (var Msg: TMsg; var Handled: Boolean) of object;

You see there is TMsg in a VCL project. Since TMsg is defined in Windows.pas is has nothing to do with the VCL style message record.