![]() |
[Autostart] Windowsstart->Tray, sonst->Form.Show
Hi zusammen,
ich stehe vor folgendem Problem. Ein Programm soll beim Windowsstart mitgestartet werden (ohne sichtbare Forms). Dafür schicke ich es in den SysTray, was soweit auch funktioniert. Dass das Programm beim Starten im Tray ist, soll aber nur geschehen, wenn es automatisch beim initialen Windowsstart geöffnet wird. Ansonsten sollte es ganz normal mit sichtbarer Form gestartet werden. Ich weiß' nicht wie ich das machen soll. Momentan prüfe ich im OnCreate mit Hilfe einer Checkbox (=autostart):
Delphi-Quellcode:
Wie man sieht wird das Programm, wenn es im Autostart steht (autostart.checked), bei jedem Start in den Tray geschickt. Ich will aber, dass das nur beim initialen Windowsstart geschieht. Kann mir da jemand weiterhelfen?
if autostart.Checked then
begin Application.ShowMainForm := FALSE; Tray.Active := TRUE; { TJvTrayIcon (JVCL) } end; Gruß Calculon -- |
Re: [Autostart] Windowsstart->Tray, sonst->Form.Show
ruf doch einfach das Programm vom Autostart mitr dem Parameter '-noform' o.Ä. auf.
im Code kannst du das dann wie folgt überprüfen:
Delphi-Quellcode:
rollstuhlfahrer
procedure FormCreate();
var i: Integer; begin for i := 1 to ParamCount do begin if UpperCase(ParamStr(i)) = '-NOFORM' then begin Application.ShowForm := false; TrayIcon.Active := true; end; end; end; |
Re: [Autostart] Windowsstart->Tray, sonst->Form.Show
Danke rollstuhlfahrer :)
hab's gerade umgesetzt und getestet und ist genauso wie ich's haben wollte! Gruß Calculon -- |
Re: [Autostart] Windowsstart->Tray, sonst->Form.Show
Schöner ist das Überprüfen mittels FindCmdLineSwitch. Dann muss man die Schleife nicht selbst implementieren und kann auf bestimmte Chars als Parameter prüfen (z.B. / - etc.). Außerdem kann man Griß-/Kleinschreibung ignorieren.
Delphi-Quellcode:
Beispiel:
type TSysCharSet = set of Char;
function FindCmdLineSwitch(const Switch: string; SwitchChars: TSysCharSet; IgnoreCase: Boolean): Boolean;
Delphi-Quellcode:
var sc: TSysCharSet;
begin sc:=['/','-','|']; if FindCmdLineSwitch('help',sc,True) then { .. Parameter ist da } |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:37 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz