动态创建窗体
2011-12-04 13:25
253 查看
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin form2 := TForm2.Create(nil); //使用Create方法创建并完成Form2的初始化 form2.Show; end; procedure TForm1.Button2Click(Sender: TObject); begin form1.Close; end; end.
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Label1: TLabel; procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin form2.Release; //释放Form2所占有的内存 end; end.
相关文章推荐
- Dll学习一_Dll 创建并动态引用窗体且释放窗体Demo
- C# 动态创建出来的窗体间的通讯 delegate1
- 在CDialog和CWnd中动态创建一个窗体的方式
- Dll学习二_Dll 窗体中动态创建数据并使用Demo
- 动态创建菜单,menustrip,根据权限显示菜单,控制菜单可用,反射,给窗体传值,反射对象传值【转】
- wpf--只是用代码动态创建 窗体
- 动态创建TImage 在窗体显示出来,动态改变大小
- Dll学习一_Dll 创建并动态引用窗体且释放窗体Demo
- Dll学习二_Dll 窗体中动态创建数据并使用Demo
- 动态创建菜单,menustrip,根据权限显示菜单,控制菜单可用,反射,给窗体传值,反射对象传值,public static Object CreateInstance ( Type type, pa
- C# 动态创建出来的窗体间的通讯 delegate2
- 动态创建菜单,menustrip,根据权限显示菜单,控制菜单可用,反射,给窗体传值,反射对象传值,public static Object CreateInstance ( Type type, params Object[] args )
- C# 如何写动态创建的窗体的控件的click等事件
- WinForm企业应用框架设计【四】动态创建业务窗体
- DELPHI动态创建窗体
- 动态创建窗体实例的三种方法
- 使用反射实现根据名称动态创建窗体的几种方法
- Ext JS动态加载JavaScript创建窗体的方法
- WinForm企业应用框架设计【四】动态创建业务窗体
- 用WeifenLuo.WinFormsUI.Docking怎么动态创建窗体