TMessage is not TMsg!

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

  1. const
  2.   WM_TEST = WM_USER + 1;
  3.  
  4. type
  5.   TForm1 = class(TForm)
  6.   public
  7.     procedure XY(var Msg : TMessage); message WM_TEST;
  8.   end;
  9.  
  10.   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.

[Update]

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

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

Send post as PDF to www.pdf24.org
convert this post to pdf.