Setting EXE icon in Delphi 7 - delphi

I'm trying to customize the icon that shows in Windows Explorer and in Desktop shortcuts for my Delphi application.
In the Delphi 7 IDE, I have loaded the desired icon in the Application tab of the Project Options dialog. It shows my desired icon as a graphic.
I didn't think it was necessary, but I also set my icon as the TMainForm Icon property.
However, the resulting EXE still shows the default D7 icon. What am I missing?

I found it after more hunting. I created a new project by copying an existing project from another folder. I forgot to change the program name at the top of the DPR file to match the name of the new project. Somehow, if a wrong name is used there, it prevents the icon from being changed in the generated EXE file...

When you assign an icon to an application, the icon will be embedded in a .res file named identical to the program name (the name mentioned in the first line of the .dpr file). When you change the program name in the .dpr file, delphi creates a new .res file with the new program name and looks for the icon resource in the new res file and finds none, and hence uses the default icon (or a rectangular white box). The old res file which carries the icon resource will no longer be used.
In summary, if you change the program name, you will have to re-assign the icon.

Maybe the icon cache needs to be deleted. There are many pages about this problem, this link might be useful: http://smallvoid.com/article/windows-icon-cache.html

Related

How to insert multi-size icon file using RC.EXE?

I created a multi-sized icon file for my application. Now i'm using a .rc file to link the icon to my app. Here is the contents of my .rc file :
MAINICON ICON myapp.ico
The file is compiled by RC.EXE, but no icon is added into my application; it keeps using the default Delphi's icon :
What am i missing ?
Thanks
The icon you specify in your *.rc file does indeed get included in the EXE, as you can easily verify using a resource editor. However, if you build using the IDE, so does the icon specified in the Project Options, and that one becomes the main icon of the application.
I almost would expect the Project Options dialog box to have some option not to include an icon, but I cannot find any such option. You can add or change the icon, but you cannot remove it if it is already there.
However, it seems like you can remove it yourself by editing the *.dproj file behind the back of the IDE:
Make sure the project is NOT opened in any instance of the Rad Studio IDE.
Open the *.dproj file in a text editor.
Remove the <Icon_MainIcon> line(s).
Save the file.
Now, if you open the project in the IDE and build it, the IDE will not insert any icon, so your icon specified in the *.rc file becomes the application icon.

Application icon stuck DELPHI XE5

The first time i update the icon in "project > Options > Application > Load Icon..." the icon as changed as it should, now every time i change the application icon, my app keep compiling with The old icon even if i click in "project > Options > Application > Default" or try to load a new one
The icon get stuck somewhere, but where ?
There's a way to force icon with resource file or unstuck the old icon ?
I download a icon which is a multi size ico file ( one ico file, 8 sizes )
i already try :
Reboot my computer.
Change the .exe name.
Copy the .exe to another computer.
same error.
For Windows platform, the icon (and version info) is stored in resource file (.res). And by default Delphi project includes in exe all the .res files it founds in project directory (see {$R *.res} directive in your .dpr file).
So check all the .res files you have in your project directory to find out which of contains the default icon. You can use any resource editor for that.
Then, just delete that file, but please keep backup, cause .res file may contain other important information.
Had the same experience recently as well.
The "default" button does not seem to work as soon as you have selected an icon.
I got rid of the icon via the following steps:
Close your project.
In your project folder an icon will be created with the name "Projectname"_ICON.ICO.
Rename or remove this Icon.
Reopen your project,
Get to Project->Options,
An error message will be raised at every configuration in which you have used the icon, but by pressing default the message will not reappear,
Now the project is forced to use the default icon again.
Probably there is a more sophisticated manner, but I have not found it elsewhere.
This was what helped me:
You can just run the following command to clear the icon cache:
ie4uinit.exe -ClearIconCache
For Windows 10, use:
ie4uinit.exe -show

Delphi .PAS code reverts to the previous code after compile/build

I have a .BPG project which has a collection of .DPR project files.
Opened a .PAS file
I changed some line of code in a .PAS file of an project.
Saved it
After changing the source code, I tried COMPILE on that project.
First it says "Compiled" successfully.
Now I see the same .PAS file, the changes were lost. Codes changed at step 2 was lost. It is having the previous code only.
The behavior is same for BUILD too.
Anyone knows about this problem?
Thanks in advance.
Update
One more hint:
.DPR Project Name is XX.dll In IDE, there is one file with name XX_TLB.PAS in that project. In this file only I tried to change some code, which got reverted after compiling/building. Now I tried to rename this file, which gave me a error message
Type Libraries must have the tlb extention.
Also can the .DCU and .PAS files be in the same directory? I entered this directory (where both .PAS and .DCU files exist) into the directories list under "Tools->Options->Delphi Options->Library - Win32"
XX_TLB.PAS files are protected files. Do not edit such files directly. In fact there is note on top of the file warning you from editing the file.
They are regenerated each time the type library is refreshed.
See Code Generated When You Import Type Library Information.
This refresh could be done by the IDE each time you compile/build your dll.
You will never edit this file because of the dependencies of a type library and registered com objects. Either you change the com object itself via the type library editor, or create a new unit that interacts with your ActiveX class.
The Delphi IDE doesn't undo changes, as a general rule. There's notable exception. When you create an empty event handler, and then save the source file, the IDE will remove that event handler. Perhaps that's what is happening.
The other possibility that occurs to me is that you have multiple copies of the file. I've known the following to happen:
You create a package containing Unit1.
You install the package.
You then make another project that contains a different Unit1. Perhaps a copy of the file in a different location, so that it looks like the same unit.
You then modify the copy of Unit1, but the IDE sometimes prefers to open the file from the package.
The bottom line is that beyond deleting empty event handlers the IDE won't undo your changes. So it seems extremely likely that you have multiple copies of the file. To get to the bottom of this, you need to get the full path to the file. In the IDE, hover over the tab with the filename and the IDE will display the full path in a hint. I suspect you'll find that you have two distinct files.

Delphi7 Remove/Restore MAINICON from Project

In Delphi7 you can assign/load an icon to a project. After every compilation your application has the assigned icon. I would like to delete/restore the icon back to the original Delphi7 Icon. I can't find a button/option for this. I also tried deleting the .res file but no luck.
Any Ideas?
The icon is stored in the .res file.
If you delete/rename your .res file with the project open in the IDE, maybe the .res data is already loaded and then will be saved again to the new .res.
Anyway, if excluding the .res file is not solving your problem, you can open the .res file with a resource editor tool (XN Resource Editor for example) and export/change/delete the MAINICON resource as you want.

Open File at Cursor Does Not Open the File in the IDE

When I mouse over the UnitNames within the Uses clause a window pops up showing the UnitName Namespace. For example when I mouseover the SysUtils unit I see SysUtils Namspace in a popup window. If I right-click on SysUtils and choose Open File at Cursor the source code opens in the IDE.
If I right-click and choose Open File at Cursor on some of the other untis I am presented with an Open File dialog box.
How come all the units don't simply just open into the IDE?
This happens when the source (.pas) file isn't on the current Search or Browsing path.
You can usually fix it by simply adding the unit to the project (right-click project in Project Manager, choose 'Add', navigate to the file, and double-click. This adds it to the .dpr file and makes it readily available to the IDE.
You can also add it to the paths using Project->Options->Delphi Compiler->Search Path or Tools->Options->Environment Options->Delphi Options->Library->Browsing Path.

Resources