Autor Beitrag
YiB
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: So 17.07.05 13:35 
Hi!
Ich hab mir grad den FAQ-Eintrag zu Trayicons angeguckt, und eigentlich geht auch alles, nur das Message Handling nicht...
1. Er sagt zu TMessage und WM_USER: Undefinierter Bezeichner...
2. und zu procedure TrayIconEvent(); message WM_TRAYICON; meint er Ungültige Botschaftsparameterliste :(

Hier ist der Source:
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:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
unit SDIMAIN;

interface

uses Windows, Classes, Graphics, Forms, Controls, Menus,
  Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, StdActns,
  ActnList, ToolWin, XPMan, ShellAPI;

type
  TForm1 = class(TForm)
    add_action: TButton;
    del_action: TButton;
    XPManifest: TXPManifest;
    action_list: TListBox;
    systray: TButton;
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure systrayClick(Sender: TObject);
    procedure del_actionClick(Sender: TObject);
    procedure add_actionClick(Sender: TObject);
  private
    IconData: TNotifyIconData;
    procedure TrayIconEvent(); message WM_TRAYICON;

  public
  end;


var
  Form1: TForm1;
  count_actions: integer;
  actions: array [0..255] of integer;

const
  WM_TRAYICON = WM_USER + 1000;


implementation


{$R *.dfm}






procedure TForm1.add_actionClick(Sender: TObject);
var
  action_name    : string;
begin
  { Get the name for the new action }
  action_name := InputBox('Neue Aktion', 'Geben sie den Namen ein!', '');

  { Increase the counter for the actions }
  count_actions := count_actions + 1;

  { Add the action to the actionlist }
  action_list.AddItem(action_name, Sender);
end;

procedure TForm1.del_actionClick(Sender: TObject);
begin
  { Delete the selected Items from the actionlist }
  action_list.DeleteSelected;

  { Decrease the counter for the actions }
  count_actions := count_actions - 1;
end;



procedure TForm1.systrayClick(Sender: TObject);
begin
  Shell_Notifyicon(NIM_ADD, @IconData);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with IconData do
  begin
    cbSize := SizeOf(TNOTIFYICONDATA);
    Wnd := Handle;
    uID := 1;
    uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
    hIcon := LoadIcon(0, IDI_INFORMATION);
    szTip := 'Tooltip';
    uCallBackMessage := WM_TRAYICON;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Shell_NotifyIcon (NIM_DELETE, @IconData);
end;



end.


Wär schön wenn mir jemand helfen könnte...

MfG YiB
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 17.07.05 17:31 
Ein Fehler ist einfach zu beheben: Du kannst WM_TRAYICON erst verwenden, wenn du es definiert hast. Also muss der const Block über der ersten Verwendung - sprich über type stehen. Außerdem würde ich sagen, dass die Methode als Parameter ein var Msg:TMessage; erwartet, um die Botschaft überhaupt auswerten zu können.

Gruß,
maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
YiB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: So 17.07.05 20:02 
Ok das mit var Msg: TMessage hab ich auch schon gehabt, aber er kennt den Typ TMessage nicht :?
EDIT: WM_USER auch nicht o_O
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 17.07.05 20:12 
Hallo!

Binde mal die Unit messages ein. Die wird normalerweise automatisch eingebunden, wenn man eine VCL-Anwendung erstellt. Danach sollte das Beispiel aus den FAQ perfekt funktionieren.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
YiB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 22

Win XP Pro, Knoppix

BeitragVerfasst: So 17.07.05 21:18 
Hey danke! Ich hab eine SDI Anwendung erstellt, deshalb war Messages noch nicht included... Jetzt gehts perfekt!! :D