小
小笨苯
Unregistered / Unconfirmed
GUEST, unregistred user!
这是非常简单的一个程序例子,具体如下:新建一个工程,在Form1上放上一个按钮Button1,再新建一个
Form2,使Form2不能自动生成,完了,就这么简单,代码如下:
----------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form2 := TForm2.Create(self);
Form2.Show;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Hide;
end;
end.
----------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure CreateParams(var Params: TCreateParams); override;
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
{ TForm2 }
procedure TForm2.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST or WS_EX_TOOLWINDOW or WS_EX_ACCEPTFILES;
Params.WndParent := GetDesktopWindow;
end;
end.
----------------------------------------
在主窗口Form1启动的时候,也将Form2动态建立,并显示出来。我的问题是:现在按下Form1
中的按钮Button1,将主窗口Form1隐藏,但在Windows的任务栏上还能显示这个程序的按钮,
请问如何隐藏按钮?在Form1再次显示的时候,任务栏上再显示按钮。
Form2,使Form2不能自动生成,完了,就这么简单,代码如下:
----------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Form2 := TForm2.Create(self);
Form2.Show;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Hide;
end;
end.
----------------------------------------
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure CreateParams(var Params: TCreateParams); override;
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
{ TForm2 }
procedure TForm2.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST or WS_EX_TOOLWINDOW or WS_EX_ACCEPTFILES;
Params.WndParent := GetDesktopWindow;
end;
end.
----------------------------------------
在主窗口Form1启动的时候,也将Form2动态建立,并显示出来。我的问题是:现在按下Form1
中的按钮Button1,将主窗口Form1隐藏,但在Windows的任务栏上还能显示这个程序的按钮,
请问如何隐藏按钮?在Form1再次显示的时候,任务栏上再显示按钮。