Autor Beitrag
fuba
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 125

Win7
D7 Ent.
BeitragVerfasst: Do 15.02.07 12:10 
Hi leute,

Ich habe nen kleines prog gemacht, das alle paar Minuten was bestimmtes machen soll, wenn es aktiv ist.

Dieses prog ist immer minimiert im Tray und würde gerne den Tray text @ laufzeit ändern.

Sollte ca. so sein (im Tray Text):
blabla programm - Status: Aktiv
blabla programm - Status: Inaktiv

Habe für tray icon einen fertigen code genommen:

ausblenden volle Höhe 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:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
Procedure TForm1.ApplicationMinimize(Sender: TObject);
var
  NotifyIconData: TNotifyIconData;
  Owner : HWnd;
begin
  Fillchar(NotifyIconData,Sizeof(NotifyIconData),0);
  NotifyIconData.cbSize := Sizeof(NotifyIconData);
  NotifyIconData.Wnd    := Handle;
  NotifyIconData.uFlags := NIF_MESSAGE
    or NIF_ICON
    or NIF_TIP;
  NotifyIconData.uCallbackMessage := WM_TASKABAREVENT;
  NotifyIconData.hIcon := Application.Icon.Handle;
  NotifyIconData.szTip := 'blabla programm - Status:';
  Shell_NotifyIcon(NIM_ADD, @NotifyIconData);


  Owner:=GetWindow(Handle,GW_OWNER);
  ShowWindow(Owner,SW_HIDE);
end;

Procedure TForm1.ApplicationMaximize(Sender: TObject);
var
  NotifyIconData: TNotifyIconData;
begin
  FillChar(NotifyIconData,Sizeof(NotifyIconData),0);
  NotifyIconData.cbSize := Sizeof(NotifyIconData);
  NotifyIconData.Wnd    := Self.Handle;
  NotifyIconData.uFlags := NIF_MESSAGE
    or NIF_ICON
    or NIF_TIP;
  NotifyIconData.uCallbackMessage := WM_TASKABAREVENT;
  NotifyIconData.hIcon := Application.Icon.Handle;
  NotifyIconData.szTip := 'Punkt';
  Shell_NotifyIcon(NIM_DELETE, @NotifyIconData);
end;


das ist der code indem der Tray Text steht:
ausblenden Delphi-Quelltext
1:
NotifyIconData.szTip := 'blabla programm - Status:';					


wie kann ich das per laufzeit ändern?

danke für hilfe!


Moderiert von user profile iconTino: Topic aus VCL (Visual Component Library) verschoben am Mo 30.04.2007 um 20:30
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 15.02.07 12:41 
Es gibt nicht nur NIM_ADD und NIM_DELETE... ;-)
msdn.microsoft.com/l...shell_notifyicon.asp
morfus
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 30.04.07 19:43 
Wie siehts denn aber aus, wenn ich Zahlen dort einfügen möchte?

Also in meinem Fall ist es eine Zeitanzeige...

danke
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 30.04.07 20:28 
user profile iconfuba hat folgendes geschrieben:
das ist der code indem der Tray Text steht:
ausblenden Delphi-Quelltext
1:
NotifyIconData.szTip := 'blabla programm - Status:';					


wie kann ich das per laufzeit ändern?


...Icons in die TNA hinzufügen, ändern und löschen?
morfus
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 01.05.07 14:31 
ja, ... ne.

das mein ich nich.
das weiss ich ja bereits.

Das Problem liegt darin, dass ich eine unbestimmte Zahlenfolge eingeben lassen möchte.
also eher etwas im Sinne von:


[highlight]IconData.szTip := 'verbleibende Restzeit: ' + TimeToStr(remTime);
Shell_NotifyIcon(NIM_Modify, @IconData);[/highlight]
(Auszug)



dann kommt eine Fehlermeldung von wegen inkompatible Typen

??

danke



EDIT//
ach mensch, mädels, ihr macht mich fertig...
habs jetze selber raus bekommen.

StrCopy(IconData.szTip, pchar(TimeToStr(remTime)))

trotzdem danke

tschausen
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 02.05.07 12:44 
Oder:
ausblenden Delphi-Quelltext
1:
IconData.szTip := PChar('verbleibende Restzeit: ' + #13#10 + TimeToStr(remTime));					

Letztendlich kommt es auf das gleiche raus.