Einzelnen Beitrag anzeigen

freimatz

Registriert seit: 20. Mai 2010
1.385 Beiträge
 
Delphi 11 Alexandria
 
#8

AW: Application.Icon setzen

  Alt 7. Apr 2018, 08:53
Funktioniert leider auch nicht - außer dass es später eine Schutzverletzung gibt (vermutlich weil es dann SplashForm und soit auch das Icon nicht mehr gibt.)

@KodeZwerg: Danke. Das sieht jetzt eher lowlevel aus. Versucht habe ich es so:
Delphi-Quellcode:
  h := LoadIcon(hInstance, 'MAINICON');
  Application.Icon.Handle := h;
  InvalidateRect(Application.Handle, nil, true);
Es funktionert aber auch nicht. Nach dem Debugger hat h einen Wert. Nach der Doku ("If the function succeeds, the return value is a handle to the newly loaded icon. If the function fails, the return value is NULL. To get extended error information, call GetLastError.") müsste das Laden ja dann geklappt haben weil h ist ja nicht NULL.
Application, Application.Icon.Handle und Application.Handle habe nach Debugger auch was drin.
Das Icon erscheint aber nicht bei mir.

Ich habe den Verdacht dass mir DevExpress da noch irgendwie reinspuckt.

Aufgrund von https://stackoverflow.com/questions/...plication-icon mein neuster letzter erfolgloser Versuch:
Delphi-Quellcode:
var
  hApp: HWND;
  hSmall : hIcon;
  hLarge : hIcon;
begin
  hApp := Application.Handle;

  hSmall := LoadImage(HInstance, 'MAINICON', IMAGE_ICON,16, 16, 0);
  hLarge := LoadImage(HInstance, 'MAINICON', IMAGE_ICON,256, 256, 0);

  SendMessage(hApp, WM_SETICON, ICON_SMALL, hSmall) ;
  SendMessage(hApp, WM_SETICON, ICON_BIG, hLarge) ;

  InvalidateRect(hApp, nil, true);
  UpdateWindow(hApp);
end;
Ich gebs mal vorläufig auf.
  Mit Zitat antworten Zitat