Autor Beitrag
F.Art
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: Mi 09.06.04 20:04 
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:
unit Unit1;

interface

uses
   ...

const
  WM_TASKBAREVENT = WM_USER+1;

type
  ...
  private
    procedure WMTASKBAREVENT(var message: TMessage);
              message WM_TASKBAREVENT;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMTASKBAREVENT(var message: TMessage);
begin
case message.LParamLo of WM_LBUTTONDOWN : begin Form1.WindowState:=wsNormal;end;
                         WM_RBUTTONDOWN : begin Form1.WindowState:=wsNormal;end;
                         WM_LBUTTONDBLCLK : begin Form1.WindowState:=wsNormal;end;
                         end;
end;  

procedure TaskBarAddIcon;
var
  tnid: TNOTIFYICONDATA ;
begin
  with tnid do
  begin
    cbSize := sizeof(TNOTIFYICONDATA);
    Wnd := Form1.handle;
    uID := 1;
    uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
    uCallbackMessage := WM_TASKBAREVENT;
    hIcon := application.icon.handle;
  end;
  strcopy(tnid.szTip,'Task Security');
  Shell_NotifyIcon(NIM_ADD, @tnid);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ShowWindow( Application.Handle, SW_HIDE );
  SetWindowLong( Application.Handle, GWL_EXSTYLE,
                 GetWindowLong(Application.Handle, GWL_EXSTYLE) or
                 WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
  ShowWindow( Application.Handle, SW_SHOW );
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
TaskBarAddIcon;
end;

end.


Solange wie die Form offen ist kann ich auf das TryIcon klicken und es fürt die Optionen aus.
Sobal ich die Form verstecke und nur noch das TryIcon da ist werden die Optionen nicht mehr ausgeführt. Wie bekomme ich es hin das ich auf das TryIcon klicke und die Form wieder erscheint?


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Sa 26.02.2005 um 20:29
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: Mi 09.06.04 20:44 
Ich glaube das Problem ist das Minimieren der Anwendung. Schreibe statt: WindowState:=wsNormal; doch mal
ausblenden Delphi-Quelltext
1:
2:
Application.Restore;
Application.BringToFront;

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Mi 09.06.04 21:27 
Der Fehler ist simpel. Aber vorher paar Punkte ;)

Das ist nicht nötig. Das geht kürzer:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.WMTASKBAREVENT(var message: TMessage);
begin
  //ShowMessage(Inttostr(message.LParamLo));
  //MessageBox(0, PChar(Inttostr(message.LParamLo)), '', IDOK);

case message.LParamLo of WM_LBUTTONDOWN : begin Form1.WindowState:=wsNormal;end;
                         WM_RBUTTONDOWN : begin Form1.WindowState:=wsNormal;end;
                         WM_LBUTTONDBLCLK : begin Form1.WindowState:=wsNormal;end;
                         end;    
end;


so:

(Hier ist übrigens auch der Fehler)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
case message.LParamLo of WM_LBUTTONDOWN : WindowState:=wsNormal;
                         WM_RBUTTONDOWN : WindowState:=wsNormal;
                         WM_LBUTTONDBLCLK : WindowState:=wsNormal;
                         end;    
end;


Das:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TaskBarAddIcon; 
var 
  tnid: TNOTIFYICONDATA ;
begin 
  with tnid do 
  begin 
    ...
    hIcon := application.icon.handle;
  end; 
  strcopy(tnid.szTip,'Task Security'); //^^^^^nach oben schieben
  Shell_NotifyIcon(NIM_ADD, @tnid);
end;


ist besser so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TaskBarAddIcon; 
var
  tnid: TNOTIFYICONDATA ;
begin
  with tnid do
  begin
    ...
    hIcon := application.icon.handle;
    strcopy(szTip,'Task Security');
  end;
  Shell_NotifyIcon(NIM_ADD, @tnid);
end;


Und wenn du sowas eingibst (SW_HIDE = Verstecken):

ausblenden Delphi-Quelltext
1:
  ShowWindow( Application.Handle, SW_HIDE);					


dann solltest es auch sichtbar machen. Ein

ausblenden Delphi-Quelltext
1:
  Form1.WindowState:=wsNormal;					


bringt nichts. Besser ist so (FEHLER LÖSUNG!!!):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.WMTASKBAREVENT(var message: TMessage);
begin
case message.LParamLo of 
    WM_LBUTTONDOWN : ShowWindow(Application.Handle, SW_NORMAL);  
    WM_RBUTTONDOWN : ShowWindow(Application.Handle, SW_NORMAL);  
    WM_LBUTTONDBLCLK : ShowWindow(Application.Handle, SW_NORMAL); 
  end; 
end;

_________________
Gruß
Martin
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: Do 10.06.04 13:18 
MartinPb hat folgendes geschrieben:
Besser ist so (FEHLER LÖSUNG!!!):

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.WMTASKBAREVENT(var message: TMessage);
begin
case message.LParamLo of 
    WM_LBUTTONDOWN : ShowWindow(Application.Handle, SW_NORMAL);  
    WM_RBUTTONDOWN : ShowWindow(Application.Handle, SW_NORMAL);  
    WM_LBUTTONDBLCLK : ShowWindow(Application.Handle, SW_NORMAL); 
  end; 
end;
Oder noch einfacher:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
case message.LParamLo of
    WM_LBUTTONDOWN,
    WM_RBUTTONDOWN,
    WM_LBUTTONDBLCLK: ShowWindow(Application.Handle, SW_NORMAL);
end;
Wenn du mal was ändern möchtest, dann muss du das nicht 3 mal sondern nur 1 mal :D

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.