can not change Delphi application icon - delphi

I change the icon in 'Project Option'-'Application'
but it does not work
so I change line in project file as
{$R *.res} to {$R .res}
but it does not work neither.
Your comment welcome

About which icon are you talking about?
If this is the icon of executable file then it is posible that the old icon was chached by windows. If you are on windows Vista and newer pressing F5 inside the explorer window will refresh all icons from all files in that forlder. On Windows XP you might be forced to log off and relog for the file incon to be reloaded.
But if you are talking about icon that is shown on title bar of your application or on taskbar button then it truely means that Delphi isn't updating the resource file corectly.
Or perhaps you have added another resource file from which icon is tried to be read from. In this case make sure that resource files are compiled in correct order.

Related

Wrong icon on task bar

Delphi XE2 app in WIndows 10, running under Parallels V11. This project was started by copying another, deleting .dsk and .local and changing form and pas file names. The dpr and .dproj were edited.
I changed the icon on the form and in Project|Options. It makes no difference if "Application.MainFormOnTaskbar := True;" is present or not. The icon that shows up on the task bar is the one from the original project. It makes no difference if the program is run in the IDE or independently. I have shut down and restarted XE and Win 10.
If I run the program on another machine(Win 7) the correct icon is shown on the task bar.
The problem went away after I restarted the computer.
Well, yes. Windows caches icons. They get refreshed after a restart.
Because the window that is rendered as a button on the taskbar and the mainwindow are two different windows.
One is Application.Handle while another is Application.MainForm.Handle
You have two options.
Change the icon in IDE's Project Options of your EXE
Do it using Windows GDI API
.
var hIcon: THandle;
hIcon := LoadIcon(MainInstance, PChar('Whatever_Taskbar_Icon_Resource_Name'));
if hIcon > 0 then
Application.Icon.Handle := hIcon;
One more exotic options is that your ico-file contains drastically different images for different Resolution/ColorDepth combinations. It is sometimes forgotten that icon files are not images but are arrays of images. Good images viewer like IrfanView, XnView, Imagine, etc should be able to display all the images of the array the .ico file contains.

delphi I'd like to make EXE which doesn't have an icon resource

I'm making many VCL form applications using delphiXE5 at present. The icon resource is unnecessary for it.
I'd like to make EXE which doesn't have an icon resource like a console application, but how should it be done?
Open your .dproj file in Notepad or similar editor and delete tags
<Icon_MainIcon>...</Icon_MainIcon>
With this approach your project will still have version information, as well as runtime themes (or custom manifests) enabled.
If you wish to add icon back, just go to Project Options -> Application and load yours or use default icon.

Wrong EXE Application Icon with Resource files

I am exploring with (.Res) resource file and found a useful tutorial on delphi.about.com site.
Tutorial Link:
http://delphi.about.com/od/objectpascalide/l/aa113099a.htm
Download test project:
http://delphi.about.com/library/aboutres.zip
I found out that the application icon is different in Windows explorer. The icon on Application form appears correctly (Refer to Image 2). The icon on Windows task bar appears correctly (refer to Image 3).
But The icon is wrong in Windows Explorer when i browse it (Refer to Image 1). It is not MAINICON from Res file.
Any idea what's wrong with it?
What do I need to configure to get the correct application icon with .EXE file?
Delphi XE3 Environment
Windows 7 Environment
You can download the sample project from above link
Image No (1)
Image No (2)
Image No (3)
Thanks in advance
Having no hint of which icon to display, the shell chooses the one with the lowest ID, or the first one that comes alphabetically. You have three icons in your executable: ICOFOLD, ICOOK and MAINICON. ICOFOLD is the one that is to be displayed in a shell folder.
The taskbar or the form icon are set by sending WM_SETICON messages once your program runs. Hence there's no guesswork there.
The icon in the Taskbar and Form window are accurate, since they come directly from the resources of the running process.
Windows Explorer, on the other hand, caches icons and sometimes that cache gets corrupted or out-of-sync. That is a well-known problem with Windows Explorer. It has nothing to do with your app. There are plenty of third-party tools available to repair the icon cache.
You can just run the following command to clear the icon cache:
ie4uinit.exe -ClearIconCache
For Windows 10, use:
ie4uinit.exe -show

EXE with multiple embedded icons

I've made a VCL application in Delphi, and set the application icon using the Project/Options dialog. I also added additional icons to the application by adding an RC file to the project. None of these is named "MAINICON" in the RC file to avoid conflict with the application icon resource.
The EXE contains all icons: the application icon, and the additional icons listed in the RC file. When I start the EXE, both the main form and the taskbar button will display the application icon, as expected.
The problem is that file managers (Explorer, Total Commander etc.) display one of the additional icons for the exe. Why? Is it possible to make the application icon displayed in file managers?
Thanks!
AFAIK Windows selects the first icon resource, in alphabetical order. So rename your addidional icon resources so that they come after MAINICON in the alphabetical order. Rebuild and clear the icon cashe to see does it fix it.

Topendialog not displaying file extensions

This problem only occurs on applications that were previously designed under Delphi 7 and migrated to Delphi 2007 running on WinXP.
I tried for ages to get this problem sorted with no luck.
As far as I am aware, the Topendialog is a Win32 dialog wrapper and it should inherit the windows folder options which, in my case, is set to show the file extensions of all files.
Now, if I create a new application and drop a Topendialog on it, when it runs, it shows the file extensions as expected.
If I drop the same dialog onto an existing application and run, it doesn't show the file extensions.
If fact if I write a filename string into the filename property before calling the dialog a la 'Myfile.txt', when the dialog is displayed the filename is shown as 'Myfile', the extension doesn't show and neither do any files in the list.
Has anyone else seem this behaviour?
Anybody have any workarounds?
Edit: Images uploaded to shown differences between Topendialog on a new project and existing project.
OK, I have a workaround for this problem.
It turns out that calling SHGetSettings in the right place actually stops the problem from occurring.
So the workaround is to put it in the project source right at the start.
eg
program Blah;
uses
Forms,shlobj,
blah,
.... etc
{$R *.TLB}
{$R *.RES}
var ShellFlags:TShellFlagState;
begin
SHGetSettings(ShellFlags,SSF_SHOWEXTENSIONS); .....
I have no idea why this makes it work, it shouldn't make any difference as its only a query but it works.
So, thanks to Justmade for suggesting that API call.

Resources