动态创建 自定义控件 不显示??

专制的网站 2012-01-06 10:15:44
我自定义了一个控件,继承自 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;

interface

uses
SysUtils, Classes, Controls;

type
TWinControl_Test = class(TWinControl)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
property Color;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('tttasd', [TWinControl_Test]);
end;

end.
...全文
194 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
maotoula 2012-07-20
  • 打赏
  • 举报
回复
parent设置成什么?
专制的网站 2012-01-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 sgzhou12345 的回复:]
编译时出现什么提示???
[/Quote]
一切正常..

[Quote=引用 2 楼 funxu 的回复:]
要设定parent
[/Quote]
还真是...
funxu 2012-01-06
  • 打赏
  • 举报
回复
要设定parent
山东蓝鸟贵薪 2012-01-06
  • 打赏
  • 举报
回复
编译时出现什么提示???

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧