我酷下载
您的位置:首页-> 技术文章-> -> Delphi-> TApplication 中CreateForm的用法

阅读排行




TApplication 中CreateForm的用法

作者未知 来源未知 加入时间:2005-9-25 人气:163
procedure CreateForm(FormClass:TFormClass;Var reference);
作用:在应用程序中创建一个新的窗体
在其参数中FormClass用来制定窗体类型,而Reference是所建立
窗体的一个变量。
动态建立窗体
program project;
...
begin
  application.initialize;
  application.CreateForm(TForm1,Form1);
  //省略Form2,Form3的建立
  application.Run;
end;
Unit Unit1;
....
implementation
uses
unit2,unit3;
{$ *.DFM}
Funcation Hasform(a:String):boolean;
var
  R:Boolean;
  X:Integer;
Begin
   r:=false;
   for x:=0 to screen.formcount-1 do
     begin
      if screen.forms[x].name =a then
         r:=true;
         
     end;
   result:=r;
End;

procedure form1.button1click(sender :tobject);
begin
if not hasform('form2') then
   begin
    applicaton.createform(Tform2,form2);
    showmessage('Form2窗体建立!');
   end;
end;
procedure form1.button2click(sender:tobject);
begin
if not hasform('Form3') then
   begin
   application.createform(Tform3,form3);
   showmessage('Form3建立!');
   end;
end;



相关文章

相关软件

联系我们 广告服务 友情链接 版权说明 软件发布 下载帮助

CopyRight
2005-2016 www.5qcn.net All Rights Reserved 版权所有 【我酷】下载