为什么我按button1就可以将窗口隐藏而在 formcreate里面加入相同的代码就不可以隐藏窗口?
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementationuses shellapi;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
    ShowWindow(Application.Handle,SW_HIDE);
    Form1.Visible := False;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
    ShowWindow(Application.Handle,SW_HIDE);
    Form1.Visible := False;
end;end.

解决方案 »

  1.   

    执行顺序 
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      然后create
      { procedure TForm1.FormCreate(Sender: TObject);
       begin
        ShowWindow(Application.Handle,SW_HIDE);
        Form1.Visible := False;
       end;}
      Application.Run;
      

  2.   

    formcreate之后还有个show的过程,你在create里面让它隐藏当然没有用
      

  3.   

    procedure TForm1.FormPaint(Sender: TObject);
    begin
      Form1.Hide;
    end;
      

  4.   

    procedure TForm1.FormPaint(Sender: TObject);
    begin
      Form1.Hide;
    end;
      

  5.   

    窗体生成的顺序是 great
     show
     active
     paint
     现在明白了 看看你在那个里写代码
      

  6.   

    搞定了,谢谢,虽然我做了一个计时器将它的 intval设成1 也可以实现隐藏,但是还是你们的方法好。改。。
      

  7.   

    一个好方法,一句代码都不要写:)
    把窗体的Left 设为 20500;
    怎么也看不到了吧:)