This example describes how to make a program not appear on the system task bar.
The initialization process of a program that adds code to the Formcreate () event of a form. In the program design phase, with the left mouse button double-click the form on the blank, on the screen will pop up a code window, the cursor moved to the formcreate () process of the processing code, and add the following code:
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
At the beginning of the program run, the code in the form formcreate () is activated first, through SetWindowLong (Application.handle,gwl_exstyle,ws_ex_toolwindow) This statement enables you to hide this program from the System task bar.
The program code is as follows:
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.
Save the file, and then press F9 to run the program, and the results of the program run as shown in Figure 1.
Program Run result chart
This example demonstrates how to make a program not appear on the system's taskbar, taking full advantage of the functionality of the SetWindowLong function, as well as many additional styles for setting up programs.