skynergy
asked on
Start application hidden
I am writing a tray icon application that needs to start with windows startup but be hidden when it starts. I'm using I param for starting up from the startup folder to start it hidden and none for starting it normal. I can't seem to get it to start hidden. Does anyone know how to do this?
Thanx in advance, Magnus.
Thanx in advance, Magnus.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yo Skynergy,
try this :
In the application source file (dpr) :
program Program1
uses
Windows,
Forms,
Unit1 in 'Unit1.pas' {Form1},
{$R *.RES}
begin
Application.Initialize;
Application.ShowMainForm := False;
Application.CreateForm(TFo rm1, Form1);
ShowWindow(Application.Han dle, SW_HIDE);
Application.Run;
end.
In unit1 do this :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
initialization
ShowWindow(Application.Han dle, SW_HIDE);
end.
Good luck
/PL
try this :
In the application source file (dpr) :
program Program1
uses
Windows,
Forms,
Unit1 in 'Unit1.pas' {Form1},
{$R *.RES}
begin
Application.Initialize;
Application.ShowMainForm := False;
Application.CreateForm(TFo
ShowWindow(Application.Han
Application.Run;
end.
In unit1 do this :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
initialization
ShowWindow(Application.Han
end.
Good luck
/PL
ASKER
Thanx guys! Peter I didn't try yours because Colin's solution worked for my application. Why did you add the extra lines of code though?
Thanks for the points.
The only extra line of code that the others suggested was
ShowWindow(Application.Han dle, SW_HIDE);
This is supposed to hide the application thread. By not showing the main form in the first place, meant it's never shown, so this line is wasted.
Colin Dawson.
The only extra line of code that the others suggested was
ShowWindow(Application.Han
This is supposed to hide the application thread. By not showing the main form in the first place, meant it's never shown, so this line is wasted.
Colin Dawson.
ASKER
If it's a tray application, that's how you enable the tray icon.
Alternatively, simply use self.hide in the mainform.
John.