当前位置: 首页 > 图文教程 > 开发语言 > Delphi > 运行时生成控件

Delphi
在线播放器DIY
关于VisiBroker For Delphi的使用(3)
关于VisiBroker For Delphi的使用(2)
关于VisiBroker For Delphi的使用(1)
Delphi的两个实用技巧(2)巧用Windows的API函数
Delphi的两个实用技巧(1)播放Flash
delphi学习:两种方法使用xml文档
Delphi与Word之间的融合技术
Delphi中动态链接库(DLL)的建立和使用
Delphi基础:Window 消息大全使用详解下
Delphi基础:Window 消息大全使用详解上
教你在DELPHI中如何调用系统对话框
Delphi开发单机瘦小数据库程序要点
用Delphi + DirectX开发简单RPG游戏
Delphi7从入门到精通之认识Delphi编辑器
Delphi7从入门到精通之历数Delphi七个版本
Delphi学习:图像放大漫游攻略
用编程来实现24小时制到12小时制的转换
一个实际的OLE服务器的开发
Delphi一点通:如何将源代码学好

Delphi 中的 运行时生成控件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 50 ::
收藏到网摘: n/a

 
㈠、运行时生成可视控件:以下以TEdit 控件为例
1.在Form的Public中定义TEdit控件
  Edit1:TEdit;
2.在需要生成的地方加入以下代码:
  Edit1:=TEdit.Create(Self);
  Edit1.Parent:=Form1;
  Edit1.Left ?:=20;
  Edit1.Top :=20;
  Edit1.Text :='Edit1 Text';
3.使用完毕后,释放分配的资源
  if? Assigned(Edit1) then Edit1.Free; ?
㈡、运行时生成非可视控件:以下以 TTimer控件为例
1.在Form的Public中定义TTimert控件
  Timer1:TTimber;
2.在需要生成的地方加入以下代码:
  Timer1:=TTimer.Create(Self);
  Timer1.OnTimer:=YourAction;
YourAction是自己定义的OnTimer事件,使用
procedure TForm1.YourAction(Sender:TObject); 完成
3.使用完毕后,释放分配的资源
  if? Assigned(Timer1) then Timer1.Free; ?