本實(shí)例介紹如何使程序不在系統(tǒng)任務(wù)條上出現(xiàn)。
程序的初始化過程,即在窗體的FormCreate()事件中添加代碼。在程序設(shè)計(jì)階段,用鼠標(biāo)的左鍵雙擊窗體上的空白處,在屏幕上就會(huì)彈出一個(gè)代碼窗口,把光標(biāo)移動(dòng)到FormCreate()過程的處理代碼中,并且添加如下代碼:
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
在程序運(yùn)行的初期,首先激活窗體FormCreate()過程中的代碼,通過SetWindowLong (Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW)這條語(yǔ)句就可以實(shí)現(xiàn)從系統(tǒng)任務(wù)條上隱藏本程序的功能。
程序代碼如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
end.
程序的初始化過程,即在窗體的FormCreate()事件中添加代碼。在程序設(shè)計(jì)階段,用鼠標(biāo)的左鍵雙擊窗體上的空白處,在屏幕上就會(huì)彈出一個(gè)代碼窗口,把光標(biāo)移動(dòng)到FormCreate()過程的處理代碼中,并且添加如下代碼:
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
在程序運(yùn)行的初期,首先激活窗體FormCreate()過程中的代碼,通過SetWindowLong (Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW)這條語(yǔ)句就可以實(shí)現(xiàn)從系統(tǒng)任務(wù)條上隱藏本程序的功能。
程序代碼如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
end.