unit frmMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure MessageEventHandler(
var Msg: TMsg;
var Handled: Boolean);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MessageEventHandler;
end;
procedure TForm1.MessageEventHandler(
var Msg: TMsg;
var Handled: Boolean);
begin
case Msg.
message of
WM_MOUSEMOVE:
begin
Invalidate();
end;
WM_PAINT:
begin
Image1.Left := Round(ScreenToClient(Mouse.CursorPos).X - Image1.Width / 2);
Image1.Top := Round(ScreenToClient(Mouse.CursorPos).Y - Image1.Height / 2);
end;
end;
end;