Usually under most circumstances you can set an icon for one of your forms and use it as the executable’s icon. However when you are not using a form in your project (classe(s) and module(s) only) you dont have the option of setting an executable icon from the Application Icon propert dropdown list (Fig. 1). There are two methods for setting an executable icon: Using a Resource File and using API code. Below are the steps for using a Resource File.
Fig. 1
So one way around this limitation is to use a resource file and embed an icon for your executable.
If you dont have the Resouce Editor AddIn loaded then you can load it by clicking on the AddIn menu > AddIn Manager … (Fig. 2). Check the Loaded / Unloaded and Load at startup checkboxes.
Fig. 2
Then click on the Project menu > Add new Resource File … and browse to the location where you would like to save the resource file to your file system. Once there give it a name and click OK. You will see a new folder located in your project explorer called “Related Documents” and it will contain the new resource file (Fig. 3).
Fig. 3
Once the resource file is added you need to bring up the Resource Editor so we can add an icon to it. Click the Tools menu > Resource Editor … Then click on the Add Icon toolbar button (Fig. 4).
Fig. 4
Now we will want to browse and select an icon file to use as our executable icon (Fig. 5).
Fig. 5
You will see that there is now a new entry named “101” under the Icon folder (Fig. 6).
Fig. 6
We need to rename this entry ID by right clicking on it and clicking Properties (Fig. 7).
Fig. 7
Name the ID to “APPICON” and click Ok.
Fig. 8
We can see the new changes (Fig. 9).
Fig. 9
Now lets test it out by compiling our project into an executable. Make sure if you do use this method with a project with forms in it that there is no form selected in the Application Icon property. After compiling the executable we can see our executable file now makes use of our custom icon (Fig. 10).
Fig. 10
Enjoy!
Filed under: Seni
