unit CanvasPanel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TCanvasPanel =
class(TPanel)
private
{ Private-Deklarationen}
fOnEraseBkgnd : TNotifyEvent;
fOnPaint : TNotifyEvent;
fMouseEnter : TNotifyEvent;
fMouseLeave : TNotifyEvent;
protected
{ Protected-Deklarationen}
protected
procedure WMEraseBkgnd (
var Message : TMessage);
message WM_ERASEBKGND;
procedure WndProc(
var Message : TMessage);
override;
procedure CMMouseEnter(
Var Message : TMessage);
message CM_MOUSEENTER;
procedure CMMouseLeave(
Var Message : TMessage);
message CM_MOUSELEAVE;
public
{ Public-Deklarationen}
constructor Create(AOwner : TComponent);
override;
property Canvas;
published
{ Published-Deklarationen }
property OnEraseBkgnd : TNotifyEvent
read fOnEraseBkgnd
write fOnEraseBkgnd;
property OnPaint : TNotifyEvent
read fOnPaint
write fOnPaint;
property OnMouseEnter : TNotifyEvent
read fMouseEnter
write fMouseEnter;
property OnMouseLeave : TNotifyEvent
read fMouseLeave
write fMouseLeave;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Beispiele', [TCanvasPanel]);
end;
procedure TCanvasPanel.CMMouseEnter(
var Message: TMessage);
begin
If Enabled
then
If Assigned(fMouseEnter)
then fMouseEnter(Self);
end;
procedure TCanvasPanel.CMMouseLeave(
var Message: TMessage);
begin
If Enabled
then
If Assigned(fMouseLeave)
then fMouseLeave(Self);
end;
constructor TCanvasPanel.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
fOnEraseBkgnd:=Nil;
fOnPaint:=Nil;
end;
procedure TCanvasPanel.WMEraseBkgnd (
var Message : TMessage);
begin
If Assigned(fOnEraseBkgnd)
then
fOnEraseBkgnd(Self);
end;
procedure TCanvasPanel.WndProc(
var Message : TMessage);
begin
Inherited;
If Message.Msg=WM_Paint
then
begin
If Assigned(fOnPaint)
then
fOnPaint(Self);
end;
end;
end.