![]() |
Re: An die Daten von PNotifyIconData herankommen
Das Icon wird so in einen Record verpackt:
Code:
Und soll am anderen Ende so wieder ausgepackt werden:
function SendData (dwMessage: Dword; lpData : PNotifyIconData) : Boolean;
type TBNApaket = record cbsize : Cardinal; Icon : HIcon; szTip : String [100]; CallBackMsg : Cardinal; Flags : Cardinal; ID : Cardinal; Wnd : HWND; dwMessage : DWord; end; var paket : TBNApaket; lppaket : ^TBNApaket; aCopyData: TCopyDataStruct; tmp : TIcon; begin // tmp := TIcon.Create; // tmp.Handle := lpData^.hIcon; lppaket := @paket; lppaket^.cbsize := lpdata.cbSize; lppaket^.Icon := lpdata.hIcon; // !!Icon verpacken lppaket^.szTip := lpdata.szTip; lppaket^.CallBackMsg := lpdata.uCallbackMessage; lppaket^.Flags := lpdata.uFlags; lppaket^.ID := lpdata.uID; lppaket^.Wnd := lpdata.Wnd; lppaket^.dwMessage := dwMessage; // tmp.free; with aCopyData do begin dwData := 0; cbData := Sizeof (paket) + 1; lpData := lppaket; end; SendMessage (FindWindow('TX11TBNA', nil), WM_COPYDATA, 0, Longint(@aCopyData)); end;
Code:
Aber das blöde Bild ist leer... :wall: Jedenfalls ist ImageList1.AddIcon(tmp) = -1 ... :gruebel:
function TX11TBNA.ImgList_AddIcon (bIcon : HIcon) : Integer;
var tmp : TIcon; begin tmp := TIcon.Create; try // If bIcon^ = 0 then ShowMessage ('Icon null'); tmp.Handle := bIcon; // <=== result := ImageList1.AddIcon(tmp); if result=-1 then // auf jeden Fall prüfen, damit man weiss was Sache ist // ShowMessage('AddIcon failed !'); // anzeigen oder sonstwie protokollieren finally tmp.Free; end; end; procedure TX11TBNA.WMCopyData (var Msg : TWMCopyData); type TBNApaket = record cbsize : Cardinal; Icon : HIcon; szTip : String [100]; CallBackMsg : Cardinal; Flags : Cardinal; ID : Cardinal; Wnd : HWND; dwMessage : DWord; end; var paket : TBNApaket; lppaket : ^TBNApaket; i, imgpos : Integer; 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; if paket.dwMessage = NIM_ADD then begin //ShowMessage ('ADD'); If imgpos < 0 then with Listview1.Items.Add do begin ImageIndex := ImgList_AddIcon (paket.Icon); //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 := ImgList_AddIcon (paket.Icon); // ImageList1.AddIcon (paket.Icon); Caption := paket.szTip; end else with Listview1.Items.Add do begin ImageIndex := ImgList_AddIcon (paket.Icon); // 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; Was kann da noch falsch sein? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:17 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