AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi IconHandle von Icon Datei
Thema durchsuchen
Ansicht
Themen-Optionen

IconHandle von Icon Datei

Ein Thema von EWeiss · begonnen am 25. Apr 2019 · letzter Beitrag vom 26. Apr 2019
 
EWeiss
(Gast)

n/a Beiträge
 
#1

IconHandle von Icon Datei

  Alt 25. Apr 2019, 20:17
Meine Funktion..

Delphi-Quellcode:
function TSkinPopUpMenu.GetHIconFromFile(AFileName: PWideChar; ASmall: Boolean; AIndex: Integer)
  : HIcon;
var
  LDummy: HIcon;
  LInfo: TSHFileInfo;
begin
  Result := 0;

  If ExtractIconEx(AFileName, -1, Result, LDummy, 0) <> 0 then
  begin
    If ASmall then
      ExtractIconEx(AFileName, AIndex, LDummy, Result, 1)
    else
      ExtractIconEx(AFileName, AIndex, Result, LDummy, 1);
  end
  else
  begin
    SHGetFileInfo(PWideChar(ExtractFileExt(AFileName)), FILE_ATTRIBUTE_NORMAL, LInfo,
      SizeOf(LInfo), IfThen(ASmall, SHGFI_SMALLICON, SHGFI_LARGEICON)
      or SHGFI_ICON or SHGFI_LINKOVERLAY or SHGFI_USEFILEATTRIBUTES);
    Result := LInfo.HIcon;
  end;
end;
Aufruf..
Delphi-Quellcode:
  if ImageIconPath <> 'then
  begin
    FIcon[ButtonCount].ImageIcon := GetHIconFromFile(ImageIconPath, true);
    if (FIcon[ButtonCount].ImageIcon <> 0) then
      btnMenu[ButtonCount].ImageDrop(HButton, FIcon[ButtonCount], X, Y, W, H);
  end;
Freigeben..
Delphi-Quellcode:
  if ButtonCount > 0 then
  begin
    for IntI := 0 to ButtonCount - 1 do
    begin
      btnMenu[IntI].ImageDropRemove(btnMenu[IntI].Handle);
      btnMenu[IntI].DestroyWindow;
      btnMenu[IntI] := nil;
    end;
    SetLength(btnMenu, 0);
    SetLength(FIcon, 0);
    ButtonCount := 0;
  end;
Funktioniert soweit alles..
Aber!

Wenn ich das PopuMenu ca.. 30 > 40 mal hintereinander aufrufe dann schlägt das fehl.
If ExtractIconEx(AFileName, -1, Result, LDummy, 0) <> 0 then

und kracht dann in
Result := LInfo.HIcon;

Warum? Wenn doch alle Icon Handles freigegeben werden.
Delphi-Quellcode:
procedure TSkinPushButton.ImageDropRemove(WinHandle: HWND);
begin

  if ImgDrop <> 0 then
  begin
    DestroyIcon(ImgDrop);
    SkinEngine.SetImageProperty(WinHandle, PROP_IMAGE_DROP, 0);
  end;
end;
gruss

Geändert von EWeiss (25. Apr 2019 um 20:20 Uhr)
  Mit Zitat antworten Zitat
 


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 08:20 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