MDI模式下,在显示MDI子窗体时,如果MDI子窗体已经显示了则不再新建此MDI子窗体,没有显示则新建此子窗体对象并显示。

解决方案 »

  1.   

    if frm_MDIChild <> nil then
      if frm_MDIChild.showing then
        什么也不用干
      else frm_MDIChild.show
    else begin
      frm_MDIChild := Tfrm_MDIChild.Create(nil);
      frm_MDIChild.show;
    end;
      

  2.   

    if (not assgined(form)) or (form=nil) then
      form:=tform.create;
      

  3.   

    begin
        if application.FindComponent('Form1')=nil then
        begin
          Application.CreateForm(TForm1, Form1);
          Form1.ShowModal;
        end
        else
          Form1.ShowModal;
    end;
      

  4.   

    if form1 = nil then
      form1 = TFrom1.Create(application);
    form1.show;