为什么我按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.
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.
Application.Initialize;
Application.CreateForm(TForm1, Form1);
然后create
{ procedure TForm1.FormCreate(Sender: TObject);
begin
ShowWindow(Application.Handle,SW_HIDE);
Form1.Visible := False;
end;}
Application.Run;
begin
Form1.Hide;
end;
begin
Form1.Hide;
end;
show
active
paint
现在明白了 看看你在那个里写代码
把窗体的Left 设为 20500;
怎么也看不到了吧:)