application.CreateForm(TForm2, Form2);
form2.Parent :=form1;
form2.Show ;
我想在前面加一个检测form2窗体是否已经被创建的语句.否则会重复出来多个form2.
但不知道怎么写.请解答.

解决方案 »

  1.   

    if form2=nil then
       application.CreateForm(TForm2, Form2); 
    form2.Parent :=form1; 
    form2.Show ;   
      

  2.   

    if form2=nil then
       application.CreateForm(TForm2, Form2); 
    form2.Parent :=form1; 
    form2.Show ;   
      

  3.   


     if application.FindComponent('Form2')<>nil then
      begin
        application.CreateForm(TForm2, Form2);
        form2.Parent :=form1;
        form2.Show ;
      end;
      

  4.   


     if application.FindComponent('Form2')<>nil then
      begin
        application.CreateForm(TForm2, Form2);
        form2.Parent :=form1;
        form2.Show ;
      end;