gud_compiuter
gud_compiuter

Reputation:

My application icon is corrupted (problems in the compiler?)

The "Application Icon" of my application is wrong.

My application shows in taskbar a different icon than the classic Delphi icon. Instead is shows the icon of one of my VCL's. That specific VCL from which the icon was "stolen" is not used in my application but other VCL's in the same package are used.

Related info: - The icon looks ok if I drag and drop my app on Desktop. - The icon looks ok in Windows Commander when I put the cursor on it. - The icon does not look ok in Windows Commander when I drag and drop it in "Button Bar". Conclusion: the icon is not accidentally changed at the runtime (the problem is there even if the application is not running).

I use Delphi 7. I disabled EurekaLog and FastMM just to be sure, and rebuild the application. The problem still persists. I have not even the slightest clue why the compiler inserts the wrong icon. I really need some hints. Thanks.

Upvotes: 3

Views: 5240

Answers (6)

Meer
Meer

Reputation: 11

Renaming the .RES file and forcing a recompiling worked out fine for me.

There are two ways to do it.

Reseting the project icon to default:

  1. Close delphi.
  2. Open the project folder in a files explorer.
  3. Rename the file extension from .RES file to .RES.BAK (You might need to uncheck the "hide file extensions for known file types" stuff in your file explorer's tools>folder options>view>advanced settings>files and folders section.
  4. Open project in delphi.
  5. It will show a warning saying it didn't find the RES file and will recreate it.

Ensuring a new icon is used and allocated with the least of memory (so that no other unused icons are allocated with the one you specify here because of previous reiterative changes in application's icon):

  1. Open project in delphi.
  2. Open the project options (Ctrl + Shift + F11).
  3. Go to application tab.
  4. Click Load Icon.
  5. Choose the desired icon and click open then click Ok.
  6. Open the project folder in a files explorer.
  7. Rename the file extension from .RES file to .RES.BAK (You might need to uncheck the "hide file extensions for known file types" stuff in your file explorer's tools>folder options>view>advanced settings>files and folders section.
  8. In delphi go to Project>Compile all projects. Then go to Project>Build All Projects.
  9. When you exit Delphi, it will ask if you want to save changes to project. Click Yes.

Hope you find this useful.

Upvotes: 1

Will Dean
Will Dean

Reputation: 39500

Have you checked this on more than one machine? Windows is notorious for icon caching problems.

Upvotes: 0

andreik
andreik

Reputation:

Check the language id of your application and default language of OS. If these don't match then you can have a troubles with icons.

Upvotes: 0

Rob Kennedy
Rob Kennedy

Reputation: 163247

The icon configured in the IDE is inserted in the RES file for your project with the name MAINICON. If you have the {$R *.RES} line in your DPR file, then the project resource file gets linked to your application by the compiler.

The icon displayed by Explorer for your EXE file is whatever the first icon in your application is. The icons or sorted alphabetically. If Explorer is showing the wrong icon, then it's likely that you have linked additional icons to your application, and one of them has a name that comes before MAINICON. It might have a numerical name. (I have no idea how Windows Commander decides what icon to display.)

If some component or other unit used by your project has a resource file linked to it with the $R directive, then it will be included in your project. You don't have to make any specific reference to the icon, or even mention the component's class name anywhere in the code. The mere presence of a $R directive in a used unit is sufficient to have the entire resource file linked in. The compiler doesn't do any "smart linking" to remove unused resources because it has no way of detecting resource usage at compile time.

The common problem is that Explorer shows the wrong icon, but the program itself uses the right one. That's fixed by renaming the "wrong" icons to come after MAINICON. But you say your program is behaving the opposite way: Explorer (the desktop) shows the right icon and your program uses the wrong one, right?

One possibility is that the $R directive in your DPR file is missing or wrong. Delphi might be linking an old version of the file. Try deleting the RES file of your project. The IDE will re-create it when it sees that it's missing. At that point, reconfigure the icon in the project options. You might also have to reset the project's version number.

You should also check the layout of the resources in your compiled program. I don't recall whether Delphi comes with a resource viewer suitable for the task. You can try PE Resource Explorer. Things to consider: What are the names of all the icons in your project? What icon appears with the name MAINICON? What RES file do the other icons come from, and what unit links it in?

Finally, a note on terminology: VCL is the Visual Component Library, the set of components that comes with Delphi. You can't have "a" VCL. The things you install to the Tool Palette (nee Component Palette) and put on forms and data modules are components, not VCLs.

Upvotes: 8

ChuckO
ChuckO

Reputation: 2573

From Delphi's Menu Bar select Project->Options

In the Project Options select Application

There you will see the Icon selected for your app.

You can change it there.

Upvotes: 5

Byron Whitlock
Byron Whitlock

Reputation: 53850

An executable can embed different size icons.

Check to make sure you have defined icons for the different sizes. Delphi might be pulling one at random if you don't have all sizes defined. This would explain why the button bar looks one way, and on the desktop it looks another.

Upvotes: 1

Related Questions