Following code demonstrates how to hook window messages using OnMessageBefore and OnMessageAfter events of acFormHook component.
procedure TForm1.acFormHook1MessageBefore(Sender: TObject;
var Message: TMessage; var Handled: Boolean);
begin with Message do case Msg of
WM_ERASEBKGND: Handled := True; // we won't to erase background ;-) Message is handled. end;
end;
procedure TForm1.acFormHook1MessageAfter(Sender: TObject;
var Message: TMessage);
begin with Message do case Msg of
WM_LBUTTONDOWN: Caption := 'left mouse button is down';
WM_MOUSEMOVE: with TWMMouseMove(Message) do
Caption := IntToStr(XPos) + ' : ' + IntToStr(YPos);
WM_NCHITTEST: with TWMNCHitTest(Message) do if Result = HTSYSMENU then { when mouse over the system menu }
Result := HTCAPTION; { form belive that this is caption } end;
end;