要在一公共單元內寫打開子窗口的過程﹐該怎么寫
請各位大師指點

解决方案 »

  1.   

    ///////////////////////////////////////////////////////////////////////////
    // 功能:    运行模态窗体                                                //
    // 入口参数:AForm: 窗体类实例                                           //
    //           AFormClass:窗体类                                           //
    //           AFormCaption:窗体标题                                     //
    // 返回值: 成功 True ;失败 False                                       //
    ///////////////////////////////////////////////////////////////////////////
    function RunShowModal(AForm:TForm;AFormClass: TFormClass;AFormCaption:String):Boolean;
    begin
       Result:=false;
       if not Assigned(AForm) then AForm:=nil;   AForm:=AFormClass.Create(Application);
       try
           AForm.Caption:=AFormCaption;
           AForm.ShowModal;
       finally
           AForm.Free;
           AForm:=nil;
        end;
      Result:=true;
    end;///////////////////////////////////////////////////////////////////////////
    // 功能:    运行非模态窗体                                              //
    // 入口参数:AForm: 窗体类实例                                           //
    //           AFormClass:窗体类                                           //
    //           Panert:容器                                                 //
    //           AFormCaption:窗体标题                                     //
    // 返回值: 成功 True ;失败 False                                       //
    ///////////////////////////////////////////////////////////////////////////
    function RunChildShow(AForm:TForm;AFormClass: TFormClass;Panert:TTrPanel;AFormCaption:String):Boolean;
    var
      i:Integer;
    begin
     Result:=false;
     for i:=0 to  Application.ComponentCount-1 do
       if (Application.Components[i] is AFormClass ) then
         begin
           // Application.MessageBox(Pchar((PanertForm.Components[i] as AFormClass).Caption),'',0);
            if (Application.Components[i] as AFormClass).Caption = AFormCaption then
             begin
               ShowWindow((Application.Components[i] as AFormClass).Handle,SW_RESTORE);
               exit;
             end;
         end; if not Assigned(AForm) then
       begin
         AForm:=AFormClass.Create(Application);
         try
             AForm.Parent:=Panert;
             AForm.Top:=0;
             AForm.Left:=0;
             AForm.Width:=Panert.Width-5;
             AForm.Height:=Panert.Height-5;
             AForm.Caption:=AFormCaption;
             AForm.Show;
         finally
         end;
       end ;
      Result:=true;
    end;
      

  2.   

    為什么我在用RunChildShow時﹐提示"can not make a visible window modal"
    我將AForm.ShowModal; 改為AForm.Show;﹐運行是時不報錯﹐但也看不到子窗口。
    為什么﹖﹖﹖