1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| unit MyCustomGraphic;
interface
uses
SysUtils, Classes, Controls;
type
TMyCustomGraphic = class(TCustomControl)
private
{ Déclarations privées }
FOnPaint : TNotifyEvent;
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
published
property Align;
property Color;
property Canvas;
property OnPaint : TNotifyEvent read FOnPaint write FOnPaint;
property OnClick;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyComponents', [TMyCustomGraphic]);
end;
constructor TMyCustomGraphic.Create(AOwner: TComponent);
begin
Inherited;
ControlStyle := ControlStyle + [csAcceptsControls];
DoubleBuffered := TRUE;
end;
procedure TMyCustomGraphic.Paint;
begin
If Assigned(FOnPaint) then FOnPaint(Self);
end; |
Partager