![]() |
Re: Tray Icon Symbol ändern.
Hallo,
so eine kleine Temperaturanzeige habe ich auch mal geschrieben. Kleiner Auszug daraus:
Delphi-Quellcode:
...
FBmpTemp.Width:= 16; FBmpTemp.Height:= FBmpTemp.Width; ... procedure TMForm.DrawBmp(Text : AnsiString); begin Text:= Format('%s°', [Text]); FBmpTemp.Canvas.TextOut((FBmpTemp.width - FBmpTemp.Canvas.TextWidth(Text)) div 2, (FBmpTemp.Height - FBmpTemp.Canvas.TextHeight(Text)) div 2, Text); FImageList.Clear; FImageList.AddMasked(FBmpTemp, clWhite); FImageList.GetIcon(0, FIcon); end; ... FGet_CPUBoardValue(addr(Value)); DrawBmp(inttostr(Value)); IconData.hIcon := FIcon.Handle; Shell_NotifyIcon(NIM_MODIFY, @IconData); ... |
Re: Tray Icon Symbol ändern.
Hey danke für den Code ! =)
Aber ich kann noch immer das Icon nicht ändern ... Was ist denn nur falsch an dem Code :gruebel:
Delphi-Quellcode:
Ich bekomme immer eine Access violation ...
procedure TForm1.Button2Click(Sender: TObject);
var fIcon: TIcon; Begin ficon.LoadFromFile(extractfilepath(application.exename) + '63.ico'); icondata.hIcon := ficon.Handle; Shell_NotifyIcon(NIM_MODIFY, @icondata); end; |
Re: Tray Icon Symbol ändern.
Fehlt da nicht ein Create? ;)
|
Re: Tray Icon Symbol ändern.
Das hatte ich auch schon vermutet, aber es bringt die gleiche Fehlermeldung...
Delphi-Quellcode:
Allerdings kommt auch ein Warnung: Variable 'fIcon' might not have been initialized
procedure TForm1.Button2Click(Sender: TObject);
var fIcon: TIcon; Begin ficon.Create; ficon.LoadFromFile(extractfilepath(application.exename) + '63.ico'); icondata.hIcon := ficon.Handle; Shell_NotifyIcon(NIM_MODIFY, @icondata); end; Habe ich da irgendwas falsch gemacht ? |
Re: Tray Icon Symbol ändern.
Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);
var fIcon: TIcon; Begin fIcon := Ticon.Create; try ficon.LoadFromFile(extractfilepath(application.exename) + '63.ico'); icondata.hIcon := ficon.Handle; Shell_NotifyIcon(NIM_MODIFY, @icondata); finally fIcon.Free; end; end; |
Re: Tray Icon Symbol ändern.
Jetzt gehts =) danke !!
:cheers: |
Re: Tray Icon Symbol ändern.
Habe es jetzt auch geschaft das icon dynamisch zu erstellen.
Delphi-Quellcode:
Hoffe irgendwer kann das gebrauchen ;)
procedure TForm1.Timer1Timer(Sender: TObject);
var zehner,einer : integer; temp: cardinal; szahl : STring; erstellticon : TIcon; begin temp :=GetGpuTemp; // gibt den Temperaturwert zurück; if temp > 100 then temp := temp - 100; szahl := inttostr(temp); zehner := strtoint(szahl[1]); einer := strtoint(szahl[2]); imagelist1.GetBitmap(zehner,image1.Picture.Bitmap); // Hier sind 10 Bilder (drin von 0 - 9) imagelist1.GetBitmap(einer,image2.Picture.Bitmap); BufferBox.Canvas.CopyMode := cmSrcCopy; BufferBox.Canvas.CopyRect(rect(0,0,16,32), image1.Canvas, rect(0,0,16,32)); BufferBox.Canvas.CopyRect(rect(16,0,32,32), image2.Canvas, rect(0,0,16,32)); ViewingBox.Canvas.CopyMode := cmSrcCopy; ViewingBox.Canvas.CopyRect(rect(0,0,32,32), BufferBox.Canvas, rect(0,0,32,32)); erstellticon:=CreateIconFromBmp(Viewingbox.Picture.Bitmap); icondata.hIcon := erstellticon.Handle; Shell_NotifyIcon(NIM_MODIFY, @icondata); end; |
Re: Tray Icon Symbol ändern.
Du solltest erstellticon noch freigeben. Ansonsten ist das ziemlich genau das, was ich gemeint hatte :thumb:
|
Re: Tray Icon Symbol ändern.
hmm wenn ich am Ende dieser Procedure erstellticon.free setzte, dann wird beim nächstem Minimieren das icon in der Tastkab nicht mehr angezeigt...
|
Re: Tray Icon Symbol ändern.
Ich vermute mal, dass CreateIconFromBmp eine benutzerdefinierte (selbstgeschriebene) Prozedur ist. Du könntest diese doch dahingehend ändern, dass Du das Icon als Parameter übergibst. Somit sparst Du Dir das ständige Neuerstellen und Zuweisen des Handles. Das könnte dann etwa so aussehen:
Delphi-Quellcode:
Getippt und nicht getestet (frei nach marabu ;) )
//erstellticon ist meinetwegen jetzt ein privates Feld
if not Assigned(erstellticon) then begin erstellticon := TIcon.Create; icondata.hIcon := erstellticon.Handle; end; CreateIconFromBmp(Viewingbox.Picture.Bitmap, erstellticon); Shell_NotifyIcon(NIM_MODIFY, @icondata); |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:05 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