Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mo 15.08.05 18:11 
hallo, ich habe folgende 2 prozeduren zum hinzufügen und entfernen eines tray icons:
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:
37:
procedure TaskBarAddIcon;
var
  tnid: TNotifyIconData;
  Owner: HWnd;
begin
  with tnid do
    begin
      cbSize := SizeOf(TNotifyIconData);
      Wnd := MainForm.Handle;
      uID := 1;
      uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
      uCallbackMessage := WM_TASKBAREVENT;
      hIcon := Application.Icon.Handle;
    end;
  StrCopy(tnid.szTip, 'Seth MP3');
  Shell_NotifyIcon(NIM_ADD, @tnid);
  Owner:=GetWindow(MainForm.Handle, GW_OWNER);
  if Owner <> 0 then
    ShowWindow(Owner,SW_HIDE);
end;

procedure TaskBarRemoveIcon;
var
  tnid: TNotifyIconData;
  Owner: HWnd;
begin
  tnid.cbSize := SizeOf(TNotifyIconData);
  tnid.Wnd := MainForm.Handle;
  tnid.uID := 1;
  Shell_NotifyIcon(NIM_DELETE, @tnid);
  Owner:=GetWindow(MainForm.Handle, GW_OWNER);
  if Owner <> 0 then
    begin
      ShowWindow(Owner, SW_Show);
      ShowWindow(Owner, SW_Normal);
    end;
end;

jetzt möchte ich den hint text des tray icons ändern, wie mache ich das ?

danke schonmal ;)
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Mo 15.08.05 19:45 
Auch das ist im FAQ-Beitrag von user profile iconTino erklärt, sogar mit extra Beispielsource...

_________________
JSXGraph
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 16.08.05 14:12 
damit bekomme ich die gleichen fehler wie mit der komponente die ich vorher hatte, nämlich mehr als ein icon, so ist das ja schon gut, das ändern kriege ich jetzt wohl auch hin, danke 8)

EDIT:

Zitat:

[Fehler] UMain.pas(203): Inkompatible Typen: 'Array' und 'String'


wie kriege ich den dazu, meine string variable zu akzeptieren ?


Zuletzt bearbeitet von F34r0fTh3D4rk am Fr 30.12.11 20:13, insgesamt 1-mal bearbeitet
F34r0fTh3D4rk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 16.08.05 14:32 
so kompiliert er es, aber es funzt net :(
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TaskBarChangeHint(HintText: String);
var
  tnid: TNotifyIconData;
begin
  with tnid do
    begin
      cbSize := SizeOf(TNotifyIconData);
      Wnd := MainForm.Handle;
      uID := 1;
      strcopy(sztip, pchar(hinttext));
    end;
  Shell_NotifyIcon(NIM_MODIFY, @tnid);
end;


na klar, der hint wird ja nur geändert, wenn das icon schon existiert, und das wird ja dann immer überschrieben, so funzt es:
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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
var
  IcoHint: string = 'default';
  IsIconic: boolean = false;

procedure TaskBarAddIcon;
var
  tnid: TNotifyIconData;
  Owner: HWnd;
begin
  with tnid do
    begin
      cbSize := SizeOf(TNotifyIconData);
      Wnd := MainForm.Handle;
      uID := 1;
      uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
      uCallbackMessage := WM_TASKBAREVENT;
      hIcon := MainForm.Icon.Handle;
    end;
  StrCopy(tnid.szTip, pchar(IcoHint));
  Shell_NotifyIcon(NIM_ADD, @tnid);
  Owner := GetWindow(MainForm.Handle, GW_OWNER);
  if Owner <> 0 then
    ShowWindow(Owner, SW_HIDE);
  IsIconic := true;
end;

procedure TaskBarRemoveIcon;
var
  tnid: TNotifyIconData;
  Owner: HWnd;
begin
  with tnid do
    begin
      cbSize := SizeOf(TNotifyIconData);
      Wnd := MainForm.Handle;
      uID := 1;
    end;
  Shell_NotifyIcon(NIM_DELETE, @tnid);
  Owner := GetWindow(MainForm.Handle, GW_OWNER);
  if Owner <> 0 then
    begin
      ShowWindow(Owner, SW_Show);
      ShowWindow(Owner, SW_Normal);
    end;
  IsIconic := false;
end;

procedure TaskBarChangeHint(HintText: String);
var
  tnid: TNotifyIconData;
begin
  if IsIconic then
    begin
      with tnid do
        begin
          cbSize := SizeOf(TNotifyIconData);
          Wnd := MainForm.Handle;
          uID := 1;
          strcopy(sztip, pchar(hinttext));
        end;
      Shell_NotifyIcon(NIM_MODIFY, @tnid);
    end;
  IcoHint := HintText;
end;


doch net, wenn ein icon besteht und ich den hint text ändern will, passiert nischt, erst wenn ich das icon wieder entferne und dann wieder hinzufüge :?

EDIT: wenn man tnid global macht funzt es !
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mi 28.01.09 19:13 
Du könntest auch TTrayIcon verwenden. Das ist in den neuen Versionen von Delphi standardmäßig dabei.