Author: Manuel Sarmiento
It shows how to act on response to windows messages. Further information can be
foun in the Online Help seeking "message handling"
Answer:
It is as easy as writing a method that complies with
Getting a TMessage Parameter or a specific Message Parameter (such as TWMMouse that
makes it easier to get the message's parameters)
Putting the reserved word message followed by the windows message to which you want
to react (such as WM_MOUSEMOVE)
Then write your method and VOILA!
Here is the code:
1 unit messageUnit;
2 3 interface4 5 uses6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
7 8 type9 TForm1 = class(TForm)
10 private11 procedure CatchMouseMove(var winMessage: TWMMouse); message wm_mousemove;
12 { Private declarations }13 public14 { Public declarations }15 end;
16 17 var18 Form1: TForm1;
19 20 implementation21 22 procedure TForm1.CatchMouseMove(var winMessage: TWMMouse);
23 {*24 WM_MOUSEMOVE25 fwKeys = wParam; // key flags26 xPos = LOWORD(lParam); // horizontal position of cursor27 yPos = HIWORD(lParam); // vertical position of cursor28 *}29 30 begin31 self.Color := TColor(winmessage.XPos)
32 end;
33 34 {$R *.DFM}35 36 end.