AGB  ·  Datenschutz  ·  Impressum  







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

Eigener Systemtray

Ein Thema von helen · begonnen am 29. Aug 2004
Antwort Antwort
helen

Registriert seit: 8. Mai 2004
42 Beiträge
 
#1

Eigener Systemtray

  Alt 29. Aug 2004, 15:53
Hallo,

ich versuche derzeit einen Ersatz für den Systemtray zu entwickeln.
Wie kann ich in meiner Anwendung das Icon, welches von der Anwendung XYZ mit

Code:
  fIcon := TIcon.Create;
  fIcon.Assign(Application.Icon);
  if not (csDesigning in ComponentState) then
  begin
    FillChar(fData, SizeOf(fData), 0);
    fData.cbSize := SizeOf(fData);
    fData.Wnd := AllocateHwnd(OnMessage); // handle to get notification message
    fData.hIcon := Icon.Handle; // icon to display
    StrPLCopy(fData.szTip, Application.Title, SizeOf(fData.szTip) - 1);
    fData.uFlags := Nif_Icon or Nif_Message;
    if Application.Title <> '' then
      fData.uFlags := fData.uFlags or Nif_Tip;
    fData.uCallbackMessage := WM_CALLBACK_MESSAGE;
    if not Shell_NotifyIcon(NIM_ADD, @fData) then // add it
      raise EOutOfResources.Create('Cannot create shell notification icon');
      {
        Replace the application's minimize and restore handlers with
        special ones for the tray. The TrayIcon component has its own
        OnMinimize and OnRestore events that the user can set.
      }
    Application.OnMinimize := AppMinimize;
    Application.OnRestore := AppRestore;
  end;
gesendet wurde in meiner Anwendung wieder als Icon auspacken?

Mein Ziel ist also, das Icon, welches mit
Code:
  fIcon := TIcon.Create;
  fIcon.Assign(Application.Icon);
  fData.hIcon := Icon.Handle;
eingepackt wurde in meiner Anwendung wieder auszupacken.

Meine Empfangsprocedure:
Code:
procedure TX11TBNA.WMCopyData (var Msg : TWMCopyData);
  type
    TBNApaket = record
       cbsize : Cardinal;
       Icon : Pointer; //HIcon;
       szTip : String [100];
       CallBackMsg : Cardinal;
       Flags : Cardinal;
       ID : Cardinal;
       Wnd : HWND;

       dwMessage : DWord;
    end;

  var paket : TBNApaket; lppaket : ^TBNApaket;
      i, imgpos : Integer; img : TICon;
begin
  lppaket := Msg.CopyDataStruct.lpData;
  paket := lppaket^;


  imgpos := -1;
  For i := 0 to Listview1.Items.Count-1 do
      if (StrToInt (Listview1.Items[i].SubItems[0]) = paket.Wnd){ and
         (StrToInt (Listview1.Items[i].SubItems[1]) = paket.uID)} then
         imgpos := I;

  img := Ticon.Create; //paket.Icon;

  if paket.dwMessage = NIM_ADD then begin
     //ShowMessage ('ADD');

     If imgpos < 0 then
        with Listview1.Items.Add do begin
              ImageIndex := ImageList1.AddIcon (img); //ImageList1.AddIcon (paket.Icon);
              Caption := paket.szTip;

              SubItems.Add (IntToStr(paket.Wnd));
              SubItems.Add (IntToStr(paket.ID));
        end;
  end
  else

  if paket.dwMessage = NIM_MODIFY then begin
     //ShowMessage ('Modify');

     If imgpos > -1 then
        with ListView1.Items [imgpos] do begin
             ImageIndex := ImageList1.AddIcon (img); // ImageList1.AddIcon (paket.Icon);
              Caption := paket.szTip;
        end
     else
         with Listview1.Items.Add do begin
              ImageIndex := ImageList1.AddIcon (img); // ImageList1.AddIcon (paket.Icon);
              Caption := paket.szTip;
             
              SubItems.Add (IntToStr(paket.Wnd));
              SubItems.Add (IntToStr(paket.ID));
        end;
  end
  else

  if paket.dwMessage = NIM_DELETE then begin
     //ShowMessage ('Delete');

     If imgpos > -1 then
        ListView1.Items.Delete (imgpos);
  end

  else ShowMessage ('Command not found!');
end;
Die 2. Frage:
Wie kann ich auf Ereignisse reagieren, wenn z.b. der Nutzer auf das Icon clickt?

Danke für die Hilfe

Helen
  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:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz