Autor Beitrag
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Di 31.01.06 11:06 
hab nen prog welches beim start von windows automatisch geladen wird. wenn man dasn programm minimiert dann verschwindet es im tray. nun wollte es so basteln, das wenn das programm beim winstart geladen wird es gleich im tray verschwindet, aber das klappt nicht.

ich benutze dazu: application.minimize; aber das wird ignoriert. es erscheint zwar das icon im tray aber das fenster bleibt
trotzdem offen. wenn ich jetzt mal zum test nen button anlege und dort den befehl hinterlege dann minimiert es die form
aber beim FormCreate ist der befehl irgendwie nutzlos. wo könnte der fehler liegen?

hier ein stück code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
procedure TForm1.FormCreate(Sender: TObject);
var
regist:TRegistry;
begin
regist:=TRegistry.Create(KEY_READ);
regist.RootKey:=HKEY_CURRENT_USER;
try
regist.OpenKey('Software\Al\',true);
Form1.Left:=regist.ReadInteger('Form1.Left');
Form1.Top:=regist.ReadInteger('Form1.Top');
Autostart:=regist.ReadInteger('Autostart');
pfad:=regist.ReadString('Pfad');
except
Form1.Left:=400;
Form1.Top:=300;
Autostart:=0;
Pfad:=paramstr(0);
end;
regist.free;
time:=now;
label1.Caption :=(TimeToStr(time));
StatusBar1.Panels[1].Text:=(TimeToStr(time));
application.minimize;
end;


Moderiert von user profile iconGausi: Beitragsformatierung überarbeitet.
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Di 31.01.06 11:08 
probiers mal mit
ausblenden Delphi-Quelltext
1:
Form1.WindowState := wsMinimized					




gruss daniel
Stübi
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 331

Win XP, Win 2000, Win ME
D5 Ent, D7 Prof, D2005 PE, C#
BeitragVerfasst: Di 31.01.06 11:11 
Könnte daran liegen, dass die Form noch gar nicht existiert (bei onCreate) Du willst was minimieren was nicht existiert.
Stell im Objektinspector der Form den Windowstate auf wsMinimized.

Gruss Stübi

_________________
Neun von zehn Stimmen in meinen Kopf sagen, dass ich nicht verrückt sei. Die zehnte summt die Tetrismelodie.
del1312 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Di 31.01.06 11:35 
hm das klappt, allerdings sieht man das programm in der taskleiste dann. also ich hab die option drin:

Autostart : ja(1) und nein(0)

wenn autostart nun 1 ist dann wird das programm beim start von windows geladen aber sollte halt im tray sein.
wenn autostart 0 ist, passiert nichts weiter ist klar dann starte ich das prog ja manuell und will auch was sehen.

hier nochmal der code denn ich jetzt angepaßt hab, aber das klappt noch nicht so recht:


Zitat:
procedure TForm1.FormCreate(Sender: TObject);
var
regist:TRegistry;
begin
regist:=TRegistry.Create(KEY_READ);
regist.RootKey:=HKEY_CURRENT_USER;
try
regist.OpenKey('Software\Al\',true);
Form1.Left:=regist.ReadInteger('Form1.Left');
Form1.Top:=regist.ReadInteger('Form1.Top');
Autostart:=regist.ReadInteger('Autostart');
pfad:=regist.ReadString('Pfad');
except
Form1.Left:=400;
Form1.Top:=300;
Autostart:=0;
Pfad:=paramstr(0);
end;
regist.free;
button3.Enabled :=false;
time:=now;
label1.Caption :=(TimeToStr(time));
StatusBar1.Panels[1].Text:=(TimeToStr(time));

if Autostart=1 then
begin
Form1.FormStyle:=fsStayOnTop;
Hide;
with NIM do begin
cbSize := SizeOf (nIM);
Wnd := Handle;
uID := 0;
uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallbackMessage := IC_CLICK;
hIcon := Application.Icon.Handle;
szTip := 'Test-Programm';
end;
Shell_NotifyIcon(NIM_ADD, @NIM);
end;


wie gesagt das icon im tray erscheint aber das programm versteckt er nicht :o(


Zuletzt bearbeitet von del1312 am Di 31.01.06 12:00, insgesamt 1-mal bearbeitet
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Di 31.01.06 11:41 
Such mal nach der Komponente CoolTrayIcon. Die hat die Option MinimizeToTray.
del1312 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Di 31.01.06 12:57 
hm naja das sieht alles wieder sehr schwierig aus, außerdem will ich ja nur minimieren wenn dsa programm automatisch starten soll, geht das damit auch? normalerweise reichte es doch die form zu verstecken mit hide, aber das tuts nicht
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Di 31.01.06 13:04 
CoolTrayIcon is eigentlich ganz einfach zu bedienen.
Damit hab ich auch schon Progs geschrieben, die beim Start ins Tray wandern.
Mir ist leider keine andere Möglichkeit bekannt, um das Prog ins Tray wandern zu lassen ohne,
dass mans anderweitig noch sieht. Sry.




gruss daniel