为什么MDI窗口在被创建时会自动Show,怎样让其不自动弹出,谢谢!

解决方案 »

  1.   

    把子FROM的VISION设置成FALSE如果不需要子FROM,我建议还是动态创建吧
      

  2.   

    mdi子窗体的visible不能设置为false,把子form从project--options中的autocreate去掉,去掉自动创建就可以了
      

  3.   

    在'工程'-'选项'中,把Auto-Create Form加到后面就可以了
      调用时用:Form1:=TForm1.create(self);
                  Form1.show;
      

  4.   

    主窗体
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      if Form2<>nil then
      Form2.Close;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      if Form2=nil then
      Form2:=TForm2.Create(nil);
    end;end.
    子窗体
    unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm2 = class(TForm)
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation{$R *.dfm}procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      Action := caFree;
      Form2:=nil;
    end;end.
      

  5.   

    打开Option,选择project栏目,把你的mdi船体改成手动创建。
      

  6.   

    谢谢大家,可是我试了好象不行,我原先也是这样做的,还是会自动弹出,我自己也在纳闷!请朋友们再指教,谢谢,或者哪位朋友可不可以做一个示例工程,发于我邮箱,可不可以[email protected] ,谢谢!
      

  7.   

    program project1;uses
      Forms,
      Form1 in 'unit.pas' {form1},
      form2 in 'unit2.pas' {form2};{$R *.res}begin
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.
    显而易见
    你从把FORM2去掉就可以了
    然后SHOW的时候再创建。
    begin
    form2:=tform2.create(application);
    form.show;
    end;
      

  8.   

    用API函数就行了.
    隐:ShowWindow(Form2.Handle,SW_HIDE);
    显:ShowWindow(Form2.Handle,SW_SHOW);