Autor Beitrag
Sina4ever
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Do 05.10.06 14:08 
Da ich Turbo Delphi verwende kann ich auf keine Komponenten zurückgreifen...

wie kann ich eine Anwendung in den Tray minimieren, so dass auf der Taskbar keine Leiste meines Programms mehr zu sehen ist...

weiterhin sollte sich beim Rechtsklick auf das Icon ein Popupmenü öffnen...

jemand nen Link oder Code für mich?

sina
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 05.10.06 14:12 
Hi!

In Uses-Klauses "shellapi" einbinden =)

"TrayPopoup" muss ein normales Popup-menue sein

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:
 
const  WM_TASKABAREVENT = WM_USER+1; //Taskbar message
 
procedure TaskbarEvent(var Msg: TMessage); Message WM_TASKABAREVENT;
procedure traycreate;
procedure traydestroy;
 
procedure TMainform.traycreate;
begin;
 {TrayIcon erzeugen}
 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;
 
 { anderes Logo als Tray-Icon
 if logo_ico.Picture.Icon.Empty = true then
  NotifyIconData.hIcon := Application.Icon.Handle
 else
  NotifyIconData.hIcon := logo_ico.Picture.Icon.Handle;
 { }

 
 NotifyIconData.szTip := 'Meine Anwendung';
 Shell_NotifyIcon(NIM_ADD, @NotifyIconData);
end;
 
procedure TMainform.traydestroy;
begin;
 {TrayIcon zerstören}
 Shell_NotifyIcon(NIM_DELETE, @NotifyIconData);
end;
 
{Message-Prozedur für das TrayIcon}
procedure TMainform.TaskbarEvent(var Msg: TMessage);
var Point : TPoint;
begin
 
  { Eventhandler }
  case Msg.LParam of
    WM_LBUTTONDBLCLK:
      begin
        Mainform.wiederherstellen1Click(mainform);
      end;
    WM_RBUTTONUP:
      begin
        {Diese Zeile ist wichtig, damit das PopupMenu korrekt wieder
geschlossen wird}

        SetForegroundWindow(Handle);
        {PopupMenu anzeigen}
        GetCursorPos(Point);
        TrayPopupMenue.Popup(Point.x, Point.y);
      end;
  end; {of case}
end;


=> Und so kanns aufgerufen werden:

ausblenden Delphi-Quelltext
1:
2:
3:
 {Anwendung in den Tray minimieren}
 traycreate;
 mainform.visible:= false; {wichtig, damit aus Taskleiste verschwindet}


=> Und so wiederhergestellt werden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
 {Anwendung wiederherstellen, Trayicon auflösen}
 mainform.WindowState:= wsnormal;
 application.Restore;
 mainform.visible:= true;
 traydestroy;


Bei Fragen: fragen!

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Sina4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Do 05.10.06 14:25 
habe jetzt folgenden code:

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:
unit Unit1;

interface

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

const
  WM_TASKABAREVENT = WM_USER+1; //Taskbar message

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    procedure TaskbarEvent(var Msg: TMessage); Message WM_TASKABAREVENT;
    procedure traycreate;
    procedure traydestroy;
    private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;



implementation

{$R *.dfm}

procedure Tform1.traycreate;
begin; 
 {TrayIcon erzeugen} 
 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;
  
 { anderes Logo als Tray-Icon 
 if logo_ico.Picture.Icon.Empty = true then 
  NotifyIconData.hIcon := Application.Icon.Handle 
 else 
  NotifyIconData.hIcon := logo_ico.Picture.Icon.Handle; 
 { }
 
  
 //NotifyIconData.szTip := 'Meine Anwendung';
 //Shell_NotifyIcon(NIM_ADD, @NotifyIconData); 
end; 
  
procedure Tform1.traydestroy;
begin; 
 {TrayIcon zerstören} 
 Shell_NotifyIcon(NIM_DELETE, @NotifyIconData); 
end; 
  
{Message-Prozedur für das TrayIcon} 
procedure Tform1.TaskbarEvent(var Msg: TMessage);
var Point : TPoint; 
begin 
  
  { Eventhandler } 
  case Msg.LParam of 
    WM_LBUTTONDBLCLK: 
      begin 
        //form1.wiederherstellen1Click(form1);
      end; 
    WM_RBUTTONUP: 
      begin 
        {Diese Zeile ist wichtig, damit das PopupMenu korrekt wieder 
geschlossen wird}
 
        SetForegroundWindow(Handle); 
        {PopupMenu anzeigen} 
        GetCursorPos(Point);
        popupmenu1.Popup(Point.x, Point.y);
      end; 
  end; {of case} 
end;

end.


doch es kommen einige fehlermeldungen:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
[Pascal Fehler] Unit1.pas(36): E2029 '(' erwartet, aber ',' gefunden
[Pascal Fehler] Unit1.pas(37): E2096 Methodenbezeichner erwartet
[Pascal Fehler] Unit1.pas(38): E2096 Methodenbezeichner erwartet
[Pascal Fehler] Unit1.pas(39): E2096 Methodenbezeichner erwartet
[Pascal Fehler] Unit1.pas(42): E2096 Methodenbezeichner erwartet
[Pascal Fehler] Unit1.pas(58): E2029 '(' erwartet, aber ')' gefunden
[Pascal Fehler] Unit1.pas(59): E2036 Variable erforderlich
[Pascal Fehler] Unit1.pas(70): E2003 Undefinierter Bezeichner: 'wiederherstellen1Click'
[Pascal Fataler Fehler] Project1.dpr(5): F2063 Verwendete Unit 'Unit1.pas' kann nicht compiliert werden
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 05.10.06 14:34 
oh sorry:

noch global deklarieren

ausblenden Delphi-Quelltext
1:
 NotifyIconData: TNotifyIconData;					


dann sollte es eigentlich funktionieren

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Sina4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Do 05.10.06 14:50 
es kommt keine fehlermeldung mehr, aber ein trayicon wird auch nicht erstellt :-(
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 05.10.06 14:57 
naja tu mal n button auf die form und ruf traycreate auf =)

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Sina4ever Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 76



BeitragVerfasst: Do 05.10.06 15:04 
ja hab ich, die form verschwindet, aber kein trayicon...habs jetzt so gelöst:

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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,cooltrayicon, StdCtrls, Menus, ImgList, ExtCtrls, XPMan;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    N1231: TMenuItem;
    ImageList1: TImageList;
    Timer1: TTimer;
    MainMenu1: TMainMenu;
    XPManifest1: TXPManifest;
    procedure N1231Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  cooltrayicon1 : tcooltrayicon;

implementation

{$R *.dfm}

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
cooltrayicon1.Free;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
cooltrayicon1 := tcooltrayicon.Create(form1);
cooltrayicon1.PopupMenu := popupmenu1;
cooltrayicon1.IconList := imagelist1;
cooltrayicon1.IconIndex := 0;
cooltrayicon1.Enabled := true;
cooltrayicon1.MinimizeToTray := true;
end;

procedure TForm1.N1231Click(Sender: TObject);
begin
cooltrayicon1.showmainform;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := false;
Application.Minimize;
cooltrayicon1.HideTaskbarIcon;
cooltrayicon1.HideMainForm;
end;

end.


Danke trotzdem!
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 05.10.06 15:21 
ähm oben im code waren wichtige bestandteile auskommentiert die das trayicon erzeugen =)
liegts vielleicht daran*g*

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 05.10.06 15:26 
das geht sicher

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:
unit Unit1;

interface

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

const  WM_TASKABAREVENT = WM_USER+1; //Taskbar message

type
  Tmainform = class(TForm)
    traypopupmenue: TPopupMenu;
    wiederherstellen1: TMenuItem;
    Button1: TButton;
    beeenden: TMenuItem;

  procedure TaskbarEvent(var Msg: TMessage); Message WM_TASKABAREVENT;
  procedure traycreate;
  procedure traydestroy;
    procedure wiederherstellen1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure beeendenClick(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  mainform: Tmainform;
  notifyicondata: TNotifyicondata;

implementation

{$R *.dfm}

procedure TMainform.traycreate;
begin;
 {TrayIcon erzeugen}
 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 := 'Meine Anwendung';
 Shell_NotifyIcon(NIM_ADD, @NotifyIconData);
end;
 
procedure TMainform.traydestroy;
begin;
 {TrayIcon zerstören}
 Shell_NotifyIcon(NIM_DELETE, @NotifyIconData);
end;

{Message-Prozedur für das TrayIcon}
procedure TMainform.TaskbarEvent(var Msg: TMessage);
var Point : TPoint;
begin

  { Eventhandler }
  case Msg.LParam of
    WM_LBUTTONDBLCLK:
      begin
        Mainform.wiederherstellen1Click(mainform);
      end;
    WM_RBUTTONUP:
      begin
        {Diese Zeile ist wichtig, damit das PopupMenu korrekt wieder
         geschlossen wird}

        SetForegroundWindow(Handle);
        {PopupMenu anzeigen}
        GetCursorPos(Point);
        TrayPopupMenue.Popup(Point.x, Point.y);
      end;
  end; {of case}
end;

procedure Tmainform.wiederherstellen1Click(Sender: TObject);
begin
 {Anwendung wiederherstellen, Trayicon auflösen}
 mainform.WindowState:= wsnormal;
 application.Restore;
 mainform.visible:= true;
 traydestroy;
end;

procedure Tmainform.Button1Click(Sender: TObject);
begin
 {=> Und so kanns aufgerufen werden: }

 {Anwendung in den Tray minimieren}
 traycreate;
 mainform.visible:= false; {wichtig, damit aus Taskleiste verschwindet}

end;

procedure Tmainform.beeendenClick(Sender: TObject);
begin
 traydestroy;
 mainform.Close;
end;

end.


LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
Timosch
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1314

Debian Squeeze, Win 7 Prof.
D7 Pers
BeitragVerfasst: Do 05.10.06 16:03 
Und wie macht man das mit .NET?

_________________
If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 05.10.06 17:46 
.NET??

puh son schwachsinn installier ich erst gar nicht =)

benutz mal die suchfunktion oder google =)

LG
STefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.