Autor Beitrag
Jagg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: Sa 06.11.04 22:18 
Hallo Leute !

Ich habe in meinem Programm geschafft,das wenn ich es minimiere, das es als TrayIcon rechts neben der Uhr erscheint !
Wie bekomme ich es jetzt hin,das mit einem rechten Mausklick auf dem Icon ein Popupmenu erscheint ?

Jagg
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: So 07.11.04 12:15 
Kommt ja drauf an welche Komponente du benutzt!

Beim CooltrayIcon ist z.B. ne Property "Popupmenu" dabei...
Jagg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 635



BeitragVerfasst: So 07.11.04 17:22 
ich benutze keine komponente
herzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 168

WINXP pro, SUSE Linux 9.0
D7 Pers.
BeitragVerfasst: So 07.11.04 20:37 
Dann hilft dir dies bestimmt weiter

www.swissdelphicente...showcode.php?id=1303
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 07.11.04 20:57 
Die Suche nach Suche in: Delphi-Forum, Delphi-Library TNA sollte Code finden zu einem kompeletten Beispiel.
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 07.11.04 21:55 
so geht bei mir immer
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:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, ExtCtrls, StdCtrls;

const WM_TASKBAREVENT = WM_USER+1;

type
  TMain1 = class(TForm)
    Startbild1: TImage;
    Timer1: TTimer;
    PopupMenu1: TPopupMenu;
    Image2: TImage;
    Merkzettelanzeigen1: TMenuItem;
    N1: TMenuItem;
    Beenden1: TMenuItem;
    Konfiguration1: TMenuItem;
    N2: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Merkzettelanzeigen1Click(Sender: TObject);
    procedure Beenden1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
     procedure WMTASKBAREVENT(var message: TMessage); message WM_TASKBAREVENT;
  end;

var
  Main1: TMain1;

implementation
uses shellapi, Unit2;
var count : integer = 0;

{$R *.DFM}


procedure TMain1.WMTASKBAREVENT(var message: TMessage);
var point : TPoint;
begin
    case message.LParamLo of
         WM_LBUTTONDBLCLK : begin
                                 Merkzettel1.show;
                            end;
         WM_RBUTTONDOWN   : begin
                                 GetCursorPos(point);
                                 popupmenu1.popup(point.x,point.y);
                            end;
    end;
end;


procedure TaskBarAddIcon;
var tnid : TNOTIFYICONDATA ;
begin
    tnid.cbSize := sizeof(TNOTIFYICONDATA); // Größenangabe der Struktur
    tnid.Wnd := Main1.handle;               // Handle des Message-Empfängers
    tnid.uID := 1;                          // ID beliebig
    tnid.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;  // siehe Tabelle
    tnid.uCallbackMessage := WM_TASKBAREVENT;        // Message# für Form1
    tnid.hIcon := Main1.image2.picture.icon.handle;  // Iconhandle
    strcopy(tnid.szTip,'Freddy');                // Tooltiptext
    Shell_NotifyIcon(NIM_ADD, @tnid);                // Registrieren ...
end;

procedure TaskBarRemoveIcon;
var tnid : TNOTIFYICONDATA ;
begin
    tnid.cbSize := sizeof(TNOTIFYICONDATA);
    tnid.Wnd := Main1.handle;
    tnid.uID := 1;
    Shell_NotifyIcon(NIM_DELETE, @tnid);
end;


procedure TMain1.FormCreate(Sender: TObject);
begin
   ShowWindow(GetWindow(handle,GW_OWNER),SW_HIDE);
end;

procedure TMain1.Timer1Timer(Sender: TObject);
begin
     inc(count);
     if count = 3 then begin
        self.hide;
        timer1.enabled := false;
        TaskBarAddIcon;
     end;
end;

procedure TMain1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  TaskBarRemoveIcon;
end;

procedure TMain1.Merkzettelanzeigen1Click(Sender: TObject);
begin
     Merkzettel1.show
end;

procedure TMain1.Beenden1Click(Sender: TObject);
begin
     close;
end;

end.


ich hoffe es hilft...

manchmal verschwindet das tray icon. warum keine ahnung.. habe da timer eingebaut mit TaskBarRemoveIcon;

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 07.11.04 23:30 
User-Xy2004 hat folgendes geschrieben:
manchmal verschwindet das tray icon. warum keine ahnung.. habe da timer eingebaut mit TaskBarRemoveIcon;

Schon mal überlegt, dass es daran liegen könnte, dass du es nicht beim Erstellen deines Fensters in die TNA einfügst? So geht es richtig: www.luckie-online.de...i/Sonstiges/TNA.html

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:
100:
101:
102:
103:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ShellAPI, Menus;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    Item11: TMenuItem;
    Item21: TMenuItem;
    Item31: TMenuItem;
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    IconData: TNotifyIconData;
  public
    { Public-Deklarationen }
    procedure WndProc(var Msg: TMessage); override;
    procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

////////////////////////////////////////////////////////////////////////////////
// auf Mausklicks reagieren, Fensterprozedur erweitern

procedure TForm1.WndProc(var Msg: TMessage);
var
  Point: TPoint;
begin
  if Msg.Msg = WM_USER + 20 then
  begin
    case Msg.lParam of
      WM_RBUTTONDOWN:
        begin
          SetForegroundWindow(Handle);
          GetCursorPos(Point);
          PopUpMenu1.PopUp(Point.X, Point.Y);
        end;
      WM_LBUTTONDOWN:
        begin
          //ShowMessage('links runter');
        end;
      WM_LBUTTONDBLCLK:
        begin
          Form1.Show;
          // Icon nur anzeigen wenn Fenster minimiert
          Shell_NotifyIcon(NIM_DELETE, @IconData);
        end;
    end;
  end;
  inherited;
end;

////////////////////////////////////////////////////////////////////////////////
// beim Minimieren Fomr verstecken und Icon in die TNA

procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
begin
  if Message.CmdType and $FFF0 = SC_MINIMIZE then
  begin
    Hide;
    // Icon nur anzeigen wenn Fenster minimiert
    Shell_NotifyIcon(NIM_ADD, @IconData);
  end
  else
    inherited;
end;

////////////////////////////////////////////////////////////////////////////////
// Beim beenden Icon entfernen

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

////////////////////////////////////////////////////////////////////////////////
// Beim Erstellen des Formulares TNotifyIconData-Struktur initialisieren

procedure TForm1.FormCreate(Sender: TObject);
begin
  //Application.ShowMainForm := False; //Programm gar nicht erst anzeigen
  IconData.cbSize := SizeOf(IconData);
  IconData.Wnd := Handle;
  IconData.uID := 100;
  IconData.uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
  IconData.uCallBackMessage := WM_USER + 20;
  IconData.hIcon := Application.Icon.Handle;
  IconData.szTip := 'Dies ist ein TNA-Icon';
  //Shell_NotifyIcon(NIM_ADD, @IconData); // fügt das Icon ein end;
end;

end.