求助:怎样避免MDI程序的子窗体重复启动

解决方案 »

  1.   

    if form2.HandleAllocated=false then
    begin
      form2:=tform2.create(nil);
      form2.show;
    end;
      

  2.   

    假设自窗体名叫form2
    if form2.HandleAllocated=false then//判断是否已经加载
    begin
      form2:=tform2.create(nil);
      form2.show;
    end;
    在form2的close事件中写上
    action:=cafree;
      

  3.   

    if Application.FindComponent('f_child')=nil then
        begin
          f_child:=Tf_child.Create(Application);
          f_child.BringToFront ;
        end
      else
        f_child.BringToFront ;
      

  4.   

    子窗体form2,窗体名为 'form2',  在form2的oncreate中,定义 h:hwnd;
      h:=findwindow(nil,'form2');
      if h<> null then showmessage('the form you have created')
      else
        application.processmessage;
      

  5.   

    function TFrmMain.FindChildForm(AName: string): Boolean;
    var
      iCount: integer;
    begin
    //
      Result := false;
      for iCount := 0 to FrmMain.MDIChildCount - 1 do
      begin
        if uppercase(AName) = uppercase((FrmMain.MDIChildren[iCount].Name)) then
        begin
          FrmMain.MDIChildren[iCount].WindowState := wsNormal;
          FrmMain.MDIChildren[iCount].BringToFront;
          Result := True;
          exit;
        end;
      end;end;
      

  6.   

    在每个窗体的onclose事件里加上form1.free
      

  7.   

    呵呵,如果是MDI里面得FRAME窗体,如何避免重复创建。
      

  8.   

    不好意思,我刚才想得太简单了,
    同意  lwk_hlj(披着狼皮的人)
    在掉用子窗体时加上
    if findchildform('form2')=false {这里是掉用它的自定义函数}
    then
      begin
        application.CreateForm(Tform2,form2);
        form2.Show;
      end
    lwk_hlj(披着狼皮的人)写的是一个自定义函数,我想你应该知道怎么写吧