вот простой пример, правда наследуемся от TGraphicControl который потомок TControl так проще рисовать
| Код | unit Unit2;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TmyControl = class(TGraphicControl) procedure Paint;Override; end;
TForm2 = class(TForm) Label1: TLabel; procedure FormCreate(Sender: TObject); private { Private declarations } public myControl: TmyControl; { Public declarations } end;
var Form2: TForm2;
implementation
uses Types;
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject); begin myControl := TmyControl.Create(Self); with myControl do begin Parent := Self; top := 10; left := 10; height := 250; Width := 200; end; end;
{ TmyControl }
{ TmyControl }
procedure TmyControl.Paint; begin inherited; Canvas.TextOut(0, 0, 'Рисуем контрол сами'); end;
end.
|
|