TApplication 中CreateForm的用法

翻译|其它|编辑:郝浩|2006-03-20 09:58:00.000|阅读 1267 次

概述:

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>


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;


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP