to thx1180
我这样写的。。你看看吧
unit1
...
...
A=class(customcontrol)
private
FLeft,FTop:Integer;
protected
constructor create(aowner:tcomponent);override;
procedure paint;override;
published
property Width;
property Height;
end;
constructor A.create(aowner:tcomponent)
begin
FLeft:=100;
FTop:=100;
Width:=10;Height:=100;
end;
procedure A.paint;
begin
with canvas do
begin
brush.color:=clred;
Rectangle(FLeft,FTop,FLeft+Width,FTop+Height)
end;
end;
unit mainForm
mainform=class(TForm)
...
...
procedure mainform.onbuttom(sender:TObject);
var a:A
begin
a:=A.Create(Self);
a.Presant:=Form;
a.show;
end;
就是显示不了画的图