Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   MAINICON laden (https://www.delphipraxis.net/147254-mainicon-laden.html)

Luckie 4. Feb 2010 14:48


MAINICON laden
 
Das Anwendungsicon legt Delphi mit der Ressourcen ID MAINICON in der Ressource ab. Wie komme ich jetzt an das Icon über die ID dran?

Delphi-Quellcode:
class procedure TAboutWnd.MsgBox(hParent: THandle; IconID: DWORD);
var
  MsgInfo          : TMsgBoxParams;
  s: String;
begin
  s := Format('%s - %s' + #13#10#13#10 + '%s' + #13#10 + '%s', [TAboutWnd.GetFileInfo(ParamStr(0), 'ProductName'),
    TAboutWnd.GetFileVersion(ParamStr(0)), COPYRIGHT, URI]);

  MsgInfo.cbSize := SizeOf(TMsgBoxParams);
  MsgInfo.hwndOwner := hParent;
  MsgInfo.hInstance := GetWindowLong(hParent, GWL_HINSTANCE);
  MsgInfo.lpszText := PChar(s);
  MsgInfo.lpszCaption := PChar(TAboutWnd.GetFileInfo(ParamStr(0), 'ProductName'));
  MsgInfo.dwStyle := MB_USERICON;
  MsgInfo.lpszIcon := MAKEINTRESOURCE(IconID);
  MessageBoxIndirect(MsgInfo);
end;
Wenn ich bei MAKEINTRESOUORCE 'MAINICON' angebe passiert nichts.

himitsu 4. Feb 2010 15:00

Re: MAINICON laden
 
Notfalls über TResourceStream in ein TIcon reinladen und dessen Handle verwenden.
ach nee, diese API will wohl die Resource :gruebel:

Uwe Raabe 4. Feb 2010 15:04

Re: MAINICON laden
 
Am einfachsten geht es über
Delphi-Quellcode:
Application.Icon

himitsu 4. Feb 2010 15:05

Re: MAINICON laden
 
[quote="Luckie"]Das Anwendungsicon legt Delphi mit der Ressourcen ID MAINICON in der Ressource ab. Wie komme ich jetzt an das Icon über die ID dran?

[add]
Zitat:

To load one of the standard system-defined icons, set the hInstance member to NULL and set lpszIcon to one of the values listed with the LoadIcon function.
??? :gruebel:
Delphi-Quellcode:
MsgInfo.hInstance := 0;
MsgInfo.dwStyle := MB_USERICON;
MsgInfo.lpszIcon := MAKEINTRESOURCE(LoadIcon(GetWindowLong(hParent, GWL_HINSTANCE), IDI_APPLICATION));
oder meinen die es so?
Delphi-Quellcode:
MsgInfo.hInstance := 0;
MsgInfo.dwStyle := MB_USERICON;
MsgInfo.lpszIcon := IDI_APPLICATION;

Luckie 4. Feb 2010 15:13

Re: MAINICON laden
 
Beide Lösungen zeigen das Icon nicht an.

DeddyH 4. Feb 2010 15:23

Re: MAINICON laden
 
Aus der Forms.pas:
Zitat:

Delphi-Quellcode:
function TApplication.GetIconHandle: HICON;
begin
  Result := FIcon.Handle;
  if Result = 0 then Result := LoadIcon(0, IDI_APPLICATION);
end;


Luckie 4. Feb 2010 15:27

Re: MAINICON laden
 
Ich brauche allerdings eine ID und kein Handle. Das ist das Problem.

DeddyH 4. Feb 2010 15:29

Re: MAINICON laden
 
Dazu hab ich im Moment leider auch keine Idee.

p80286 5. Feb 2010 13:31

Re: MAINICON laden
 
Hilft Dir Das vielleicht weiter?
ist zwar c+ ...

Gruß
K-H

Luckie 5. Feb 2010 13:44

Re: MAINICON laden
 
Nein, ich will ja keine Ressource ändern.


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:59 Uhr.
Seite 1 von 2  1 2      

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