Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Icon des Delphi Projectes einstellen über Quellcode (https://www.delphipraxis.net/77568-icon-des-delphi-projectes-einstellen-ueber-quellcode.html)

Corpsman 21. Sep 2006 10:34


Icon des Delphi Projectes einstellen über Quellcode
 
Hi Leuts,

Ich will das Icon meiner Exe ändern.

Normalerweise macht man das ja über Projekt/Optionen/Anwendung/ und dann lade ich es da rein.

Mein Problem ist nur das ich die Res datei des Projektes andauernd löschen mus.

Ergo will ich es einbinden.

Mit
Delphi-Quellcode:
Program Project1;

{$R 'Icon.res' 'Icon.rc'} // Einbinden der Icon Ressource in "Icon.rc" steht der Index 1

Uses
  Forms,
  shellapi, // benötigt fürs laden des Icons
  graphics, // benötigt fürs laden des Icons
  Unit1 In 'Unit1.pas' {Form1};

{$R *.RES}

Var // benötigt fürs laden des Icons
  Icon: TIcon; // benötigt fürs laden des Icons
Begin
  Icon := TIcon.Create; // benötigt fürs laden des Icons
  Try // benötigt fürs laden des Icons
    Icon.Handle := ExtractIcon(hinstance, pchar(paramstr(0)), 1); // benötigt fürs laden des Icons
    Application.Icon.Assign(Icon); // benötigt fürs laden des Icons
  Finally // benötigt fürs laden des Icons
    Icon.Free; // benötigt fürs laden des Icons
  End; // benötigt fürs laden des Icons
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
End.
und der Ivon.rc
Delphi-Quellcode:
1 ICON DISCARDABLE "icon.ico"
Lädt meine Anwendung auch wunderbar das Icon.

Nur eben die Exe Datei ansich hat noch das Delphi Icon.

Wenn ich das Gleiche mit einer NonVCL anwendung mache geht es aber.

Die frage ist nun was mus ich ändern das es in meinem VCL Project auch geht ?

Corpsman 22. Sep 2006 07:24

Re: Icon des Delphi Projectes einstellen über Quellcode
 
Ho,

Zum Glück habe ich noch andere Quellen. Das Problem ist nun gelöst Hier also für alle die Lösung :

Die Icon.rc mus geändert werden in

Delphi-Quellcode:
MAINICON ICON DISCARDABLE "icon.ico"
und die project1.dpr ändert sich dann zu :
Delphi-Quellcode:
Program Project1;

Uses

  Forms,
  shellapi, // benötigt fürs laden des Icons
  graphics, // benötigt fürs laden des Icons
  Unit1 In 'Unit1.pas' {Form1};

{$R 'Icon.res' 'Icon.rc'} // Einbinden der Icon Ressource in "Icon.rc" steht der Index 0

//{$R *.RES} // Das einbinden dieser Ressource entfällt nun wer weitere Ressourcen einbinden will mus dies nun in Icon.rc machen

Var // benötigt fürs laden des Icons
  Icon: TIcon; // benötigt fürs laden des Icons
Begin
  Icon := TIcon.Create; // benötigt fürs laden des Icons
  Try // benötigt fürs laden des Icons
    Icon.Handle := ExtractIcon(hinstance, pchar(paramstr(0)), 0); // benötigt fürs laden des Icons
    Application.Icon.Assign(Icon); // benötigt fürs laden des Icons
  Finally // benötigt fürs laden des Icons
    Icon.Free; // benötigt fürs laden des Icons
  End; // benötigt fürs laden des Icons
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
End.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:30 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