AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Windows messages der Taskbar?

Ein Thema von Helmi · begonnen am 29. Sep 2004 · letzter Beitrag vom 8. Nov 2004
Antwort Antwort
Benutzerbild von Remote1
Remote1

Registriert seit: 22. Okt 2003
Ort: Dippoldiswalde
252 Beiträge
 
Delphi 6 Personal
 
#1

Re: Windows messages der Taskbar?

  Alt 29. Sep 2004, 22:02
schau dir mal das an:
Zitat:
Dafür gibt es die API-Funktion Shell_NotifyIcon() und den Daten-Record TNotifyIconData. Und so bindet man das ganze in ein Programm ein (Beispiel von Heino Tiedemann):
Delphi-Quellcode:
uses
  ShellAPI;

const
  WM_TASKABAREVENT = WM_USER+1; //Taskbar message
[...]

type
  TMainForm = class(TForm)
[...]
private
    { Private-Deklarationen }
    procedure TaskbarEvent(var Msg: TMessage);
      Message WM_TASKABAREVENT;
[...]

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

  { Die WM_TaskbarEvent-Message "Msg" gibt in Msg.LParam
    das genaue Ereignis an. Msg.LParam kann folgende Werte für
    Mausereignisse annehmen:

    WM_MouseMove
    WM_LButtonDown
    WM_LButtonUp
    WM_LButtonDblClk
    WM_RButtonDown
    WM_RButtonUp
    WM_RButtonDblClk }


  { Eventhandler-Beispiele von Robert Fischer: }
  case Msg.LParam of
    WM_LBUTTONDBLCLK:
      begin
        //Mach etwas nach einem Doppelklick...
      end;
    WM_LBUTTONUP:
      begin
        //Mach etwas nach einem Linksklick...
      end;
    WM_RBUTTONUP:
      begin
        // Rechtsklick
        // Diese Zeile ist wichtig, damit das PopupMenu korrekt
        // wieder geschlossen wird:
        SetForegroundWindow(Handle);
        // PopupMenu anzeigen:
        GetCursorPos(Point);
        PopupMenu1.Popup(Point.x, Point.y);
        //oder ohne Variable Point:
        //PopupMenu1.Popup(Mouse.CursorPos.x, Mouse.CursorPos.y);
      end;
  end;
end;

{TrayIcon mit dem Hauptformular erzeugen}
procedure TMainForm.FormCreate(Sender: TObject);
var
  NotifyIconData: TNotifyIconData;
begin
  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 := 'Hinweistext für das TrayIcon';
  Shell_NotifyIcon(NIM_ADD, @NotifyIconData);
end;

{TrayIcon mit dem Hauptformular zerstören}
procedure TMainForm.FormDestroy(Sender: TObject);
var
  NotifyIconData: TNotifyIconData;
begin
  FillChar(NotifyIconData,Sizeof(NotifyIconData),0);
  NotifyIconData.cbSize := Sizeof(NotifyIconData);
  NotifyIconData.Wnd := Self.Handle;
  NotifyIconData.uFlags := NIF_MESSAGE
    or NIF_ICON
    or NIF_TIP;
  NotifyIconData.uCallbackMessage := WM_TASKABAREVENT;
  NotifyIconData.hIcon := Application.Icon.Handle;
  NotifyIconData.szTip := 'Punkt';
  Shell_NotifyIcon(NIM_DELETE, @NotifyIconData);
end;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz