我这里有一个别人写的简单控件,但忘了是谁的.
在原有Panel基础上加上Canvas, 及OnPaint
unit DPanel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TDPanel = class(TPanel)
private
fPaint:TNotifyEvent;
{ Private declarations }
protected
procedure Paint;override;
{ Protected declarations }
public
property canvas;
{ Public declarations }
published
property OnPaint:TNotifyEvent read fPaint write fPaint;
{ Published declarations }
end;
procedure Register;
implementation
procedure TDPanel.Paint;
begin
inherited;
if Assigned(fPaint) then
fPaint(self);
end;
procedure Register;
begin
RegisterComponents('New ComponentS', [TDPanel]);
end;
end.