unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, AppEvnts;

type
  TForm1 = class(TForm)
    ApplicationEvents1: TApplicationEvents;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
case (Msg.message) of
  WM_MOUSEMOVE, WM_NCMOUSEMOVE:
    begin
    if Msg.message=WM_MOUSEMOVE then Label1.Caption:='W obrębie obszaru użytkownika formy (wsp. okna)'
                                else Label1.Caption:='Poza obszarem użytkownika formy (wsp. ekranu)';
    Label2.Caption:=IntToStr(LOWORD(Msg.lParam));
    Label4.Caption:=IntToStr(HIWORD(Msg.lParam));
    //unikam uzycia GetWindowText(Msg.hwnd, zeby uniknac klopotow z argumentami lancuchowymi
    if (Msg.hwnd=Form1.Handle) then
      Label5.Caption:='Nadawca: Form1'
      else
      Label5.Caption:='Nadawca: Form2';
    Label6.Caption:='Czas: '+IntToStr(Msg.time);
    end;
  end;
end;

end.
