Hi,
Subclassing wäre noch eine andere Möglichkeit.
Delphi-Quellcode:
private
OldWindowProc: TWndMethod;
procedure PanSubClassWndProc(var Message: TMessage);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PanSubClassWndProc(var Message: TMessage);
begin
case Message.Msg of
CM_MOUSELEAVE: Panel1.Color := clBlack;
CM_MOUSEENTER: Panel1.Color := clGreen;
end;
OldWindowProc(Message);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
OldWindowProc:= Panel1.WindowProc;
Panel1.WindowProc:= PanSubClassWndProc;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Panel1.WindowProc:= OldWindowProc;
end;