动态创建 自定义控件 不显示??
我自定义了一个控件,继承自 TWinControl ,也安装好了,在设计界面期间把控件拖放到form上,是ok的,但是动态创建的话,就不显示,是为什么??
动态创建的代码:
procedure TForm1.Button9Click(Sender: TObject);begin FWinControl_Test1 := TWinControl_Test.Create(self); FWinControl_Test1.Left := 0; FWinControl_Test1.Top := 0; FWinControl_Test1.Width := 200; FWinControl_Test1.Height := 200; FWinControl_Test1.Color := clWhite; FWinControl_Test1.Show;end;
unit WinControl_Test;interfaceuses SysUtils, Classes, Controls;type TWinControl_Test = class(TWinControl) private { Private declarations } protected { Protected declarations } public { Public declarations } published property Color; end;procedure Register;implementationprocedure Register;begin RegisterComponents('tttasd', [TWinControl_Test]);end;end.