TApplication 中CreateForm的用法

王朝delphi·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

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;

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航