It is possible to create an
application that once run, will not appear on the task bar or appear in the
currently running applications window. This is accomplished by setting the Application.ShowMainForm
:= False;. The source
below illustrates an example DPR file.
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas'
{Form1};
{$R *.res}
begin
Application.Initialize;
Application.ShowMainForm:=False;
Application.CreateForm(TForm1,
Form1);
Application.CreateForm(TForm2,
Form2);
Application.Run;
end.
In Windows 2000 the
application will appear in the Processes tab. This is also where you would
terminate the program as well.
Setting ShowMainForm to false allows for an application
to run similar to that of a service. Great for applications that need to
constantly check for external events or conditions to occur.
other
procedure TForm1.Button1Click(Sender: TObject);
var
frmRegion, tempRegion: HRGN;
i: Integer;
Arect: TRect;
Begin
frmRegion := 0;
for I:= 0 to ControlCount - 1 Do
begin
aRect := Controls[i].BoundsRect;
OffsetRect( aRect, clientorigin.x - left,
clientorigin.y - top );
tempRegion := CreateRectRgnIndirect( aRect );
if frmRegion = 0 Then
frm Region := tempRegion
else
begin
CombineRgn( frmRegion, frmRegion,
tempRegion, RGN_OR );
DeleteObject( tempRegion );
end;
end;
CombineRgn( frmRegion, frmRegion, tempRegion, RGN_OR );
SetWindowRgn( handle, frmRegion, True );
DeleteObject( tempRegion );
end;