Einzelnen Beitrag anzeigen

A-M-X

Registriert seit: 29. Sep 2005
Ort: Karlsruhe
152 Beiträge
 
#3

Re: Systray + Gauge1.Progress = FEHLOOOOR

  Alt 12. Nov 2005, 14:17
so sieht der beispielcode einer homepage aus:

Delphi-Quellcode:
unit Unit1;

interface

uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ShellApi, AppEvnts;

const
  IC_CLICK = WM_APP + 201;

type
  TForm1 = class(TForm)
    ApplicationEvents1: TApplicationEvents;
    procedure ApplicationEvents1Minimize(Sender: TObject);
    private
      { Private-Deklarationen }
      procedure Systray(var sMsg: TMessage); message IC_CLICK;
    public
      { Public-Deklarationen }
    end;

var
  Form1: TForm1;
  NIM : TNotifyIconData;

implementation

{$R *.DFM}

procedure TForm1.Systray(var sMsg: TMessage);
begin
  // Vorgang: Klick auf das Icon neben der Uhr und Anzeige der Anwendung
  inherited;
  if (sMsg.LParam = WM_LBUTTONDOWN) then begin
    Show;
    Shell_NotifyIcon(NIM_DELETE, @NIM);
    Application.Restore; //zeigt die Anwendung wieder an
  end;
end;

procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
  //Vorgang: Minimieren der Anwendung, Entfernung des Taskleisteneintrags
  //und Hinzufügen des Programmicons neben der Uhr
  Form1.FormStyle:=fsStayOnTop;
  Hide;
  with NIM do begin
    cbSize := SizeOf (nIM);
    Wnd := Handle;
    uID := 0;
    uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
    uCallbackMessage := IC_CLICK;
    hIcon := Application.Icon.Handle;
    szTip := 'Test-Programm';
  end;
  Shell_NotifyIcon(NIM_ADD, @NIM);
end;

end.
  Mit Zitat antworten Zitat