Autor Beitrag
RichiDD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Sa 21.12.02 14:15 
ich bin wahrscheinlich blos zu blöd aber ich hab kein plan wie ich mit dem code umgehen soll. kann mir bitte einer helfen und ein paar kommentare zu dem code schreiben.
ausblenden volle Höhe 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:
unit Unit1; 

interface 

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

const 
  WM_TASKABAREVENT = WM_USER + 1; 

type 
  TForm1 = class(TForm) 
    PopupMenu1: TPopupMenu;
    Close1: TMenuItem;
    procedure FormDestroy(Sender: TObject); 
    procedure Close1Click(Sender: TObject); 
    procedure FormShow(Sender: TObject); 
    procedure FormCreate(Sender: TObject);
  private 
    NotifyIconData: TNotifyIconData; 
    { Private-Deklarationen } 
    procedure TaskbarEvent(var Msg: TMessage); Message WM_TASKABAREVENT; 
  public 
    { Public-Deklarationen } 
  end;

var 
  Form1: TForm1; 

implementation 

{$R *.dfm} 

procedure TForm1.TaskbarEvent(var Msg: TMessage); 
begin 
  case Msg.LParam of 
    WM_LBUTTONDBLCLK:
      begin
        // doppelclick
      end;
    WM_LBUTTONUP: 
      begin
        //Mach etwas nach einem Linksklick... 
      end; 
    WM_RBUTTONUP: 
      begin 
        // Rechtsklick
        SetForegroundWindow(Handle);
        PopupMenu1.Popup(Mouse.CursorPos.x, Mouse.CursorPos.y); 
      end; 
  end; 
end; 

procedure TForm1.FormDestroy(Sender: TObject);
begin 
  with NotifyIconData do begin 
    Wnd   := Self.Handle; 
    szTip := 'Punkt'; 
  end; 
  Shell_NotifyIcon(NIM_DELETE, @NotifyIconData); 
end; 

procedure TForm1.Close1Click(Sender: TObject); 
begin 
  Close;
end; 

procedure TForm1.FormShow(Sender: TObject);
begin
  ShowWindow(GetWindow(Handle,GW_OWNER), SW_HIDE);
end; 

procedure TForm1.FormCreate(Sender: TObject); 
begin
  Application.ShowMainForm:= False; 
  Fillchar(NotifyIconData,Sizeof(NotifyIconData),0); 
  with NotifyIconData do begin 
    cbSize           := Sizeof(NotifyIconData); 
    Wnd              := Handle; 
    uFlags           := NIF_MESSAGE or NIF_ICON or NIF_TIP; 
    uCallbackMessage := WM_TASKABAREVENT; 
    hIcon            := Application.Icon.Handle; 
    szTip            := 'Meine Anwendung'; 
  end; 
  Shell_NotifyIcon(NIM_ADD, @NotifyIconData); 
end; 

end.


ich währe ja eigentlich schon froh wenn man mir erklären würde wie ich aus dem Trayicon wieder eine normale oberfläche bekomme.

danke im voraus
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 21.12.02 16:42 
Ersetzt doch mal //doppelklick durch:
ausblenden Quelltext
1:
Form1.Show;					

Wäre das nicht eine Idee?
RichiDD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Sa 21.12.02 17:28 
Titel: hmmm ?
ja das geht schon aber leider hab ich dann immernoch das trayicon unten in der ecke und da soll aber keins mehr sein wenn ich form1.show für doppelklick einsetzte.

aber trotzdem danke.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 21.12.02 17:29 
Wie bekommst du es denn weg, wenn du dein Programm beendest? :roll:
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 22.12.02 15:34 
Das nächste mal bitte nicht per PM, sondern hier im Forum posten. Kalr verschwindet es, wenn du Close; aufrufst., weil nach close nämlich noch dieser Code:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.FormDestroy(Sender: TObject); 
begin 
  with NotifyIconData do begin 
    Wnd   := Self.Handle; 
    szTip := 'Punkt'; 
  end; 
  Shell_NotifyIcon(NIM_DELETE, @NotifyIconData); 
end;

Ausgeführt wird. So, und jetzt sag mir was dafür sorgt, dass das TrayIcon verschwindet? Close ist es nicht und automatisch geht es auch nicht.

Btw. der Teil mit With NotifyIconData do... ist an dieser Stelle überflüssig.
RichiDD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: So 22.12.02 15:45 
Titel: trayicon
wenn ich das prog starte hab ich gleich ein trayicon. ich hab ein popupmenü eingefügt das ein close button enthält
ausblenden Quelltext
1:
2:
3:
4:
procedure TForm1.Close1Click(Sender: TObject); 
begin 
  Close;
end;

das popup hab ich in den taskbar ivent eingebunden
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.TaskbarEvent(var Msg: TMessage); 
begin 
  case Msg.LParam of 
    WM_LBUTTONDBLCLK:
      begin
        // doppelclick
      end;
    WM_LBUTTONUP: 
      begin
        //Mach etwas nach einem Linksklick... 
      end; 
    WM_RBUTTONUP: 
      begin 
        // Rechtsklick
        SetForegroundWindow(Handle);
        PopupMenu1.Popup(Mouse.CursorPos.x, Mouse.CursorPos.y); 
      end; 
  end; 
end;


also mehr hab ich an dem code nicht geändert den rest hab ich blos 1:1 gezogen
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 22.12.02 16:03 
Titel: Re: trayicon
RichiDD hat folgendes geschrieben:

also mehr hab ich an dem code nicht geändert den rest hab ich blos 1:1 gezogen

Das habe ich gemerkt, deswegen hat meine Frage darauf abgezielt, dass du dich mit dem Code auseinandersetzt. Also wenn du rausgefunden hast, welche Code-Zeile für das Löschen verantwortlich ist, dann hass du deine Lösung.
RichiDD Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: So 22.12.02 17:39 
irgendwie hab ich keinen durchblick mehr :nixweiss: alles was funzt is das
ausblenden Quelltext
1:
Form1.Show;					

aber vieleicht würde es mir helfen wenn du mir helfen wen du mir erklärst was diese procedure im einzelnen macht
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.ShowMainForm:= False;
  Fillchar(NotifyIconData,Sizeof(NotifyIconData),0);
  with NotifyIconData do begin
    cbSize           := Sizeof(NotifyIconData);
    Wnd              := Handle;
    uFlags           := NIF_MESSAGE or NIF_ICON or NIF_TIP;
    uCallbackMessage := WM_TASKABAREVENT;
    hIcon            := Application.Icon.Handle;
    szTip            := 'Meine Anwendung';
  end;
  Shell_NotifyIcon(NIM_ADD, @NotifyIconData);
end;


da ich nochdem ich das programm ausführe keine Form mehr sehe sondern nur das trayicon und wenn ich weis wie man so ein icon erzeugt kann ich es bestimmt auch wieder verschwinden lassen :autsch:
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 22.12.02 17:50 
Also. *tieflufthol*:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.FormCreate(Sender: TObject); 
begin 
  Application.ShowMainForm:= False; 
  Fillchar(NotifyIconData,Sizeof(NotifyIconData),0); 
  with NotifyIconData do begin 
    cbSize           := Sizeof(NotifyIconData); 
    Wnd              := Handle; 
    uFlags           := NIF_MESSAGE or NIF_ICON or NIF_TIP; 
    uCallbackMessage := WM_TASKABAREVENT; 
    hIcon            := Application.Icon.Handle; 
    szTip            := 'Meine Anwendung'; 
  end; 
  Shell_NotifyIcon(NIM_ADD, @NotifyIconData); 
end;

Hier wird die TrayIcon-Struktur initialisiert und mit Werten gefüllt. Mit Shell_Notifyicon(Nim_ADD, @NitifyIconData); wird dann das Icon erzeugt. Die erste zeile Application.ShowMainForm ist, denke ich, überflüssig. Wenn du sie Weg läßt, sparst du dir auch auch das Form1. Show.

Mit Shell_NotifyIcon(NIM_DELETE, @NotifyIconData); entfernst du es wieder aus der TNA.

Und das:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.TaskbarEvent(var Msg: TMessage); 
begin 
  case Msg.LParam of 
    WM_LBUTTONDBLCLK: 
      begin 
        // doppelclick 
      end; 
    WM_LBUTTONUP: 
      begin 
        //Mach etwas nach einem Linksklick... 
      end; 
    WM_RBUTTONUP: 
      begin 
        // Rechtsklick 
        SetForegroundWindow(Handle); 
        PopupMenu1.Popup(Mouse.CursorPos.x, Mouse.CursorPos.y); 
      end; 
  end; 
end;

Ist der Event-Handler für das Icon in der TNA.