Wrong icon on task bar - delphi

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.

Related

Wrong exe icon in windows explorer when using resource file

I have an FMX application created in RAD studio 10.4 and have set the main icon in Project Options, Icons. I have also added 2 additional icons in the resource file using Resources and Images, which will be used by an installer to create file associations. All icons are 32x32 pixels. The main icon appears correctly in the application title bar but not in Windows explorer. It always takes the first of the 2 additional icons in the resource file. At first I thought this could be due to windows caching of icons but it is not. I'm using software called icofx to extract the icons from the exe and I see that the main icon always appears last.
I have tried changing the identifiers in Resources and images with the same result. The identifiers shown in icofx are not the ones I set. I've also tried renaming the additional icons so that they're last alphabetically, but that doesn't work either.
If I try the same with an old Delphi 7 project then it always results in the main application icon appearing first, which is what I want. Any ideas?
I have now resolved the issue by changing the identifiers of the additional icons so that they come after MAINICON alphabetically. The default is Icon_1, Icon_2, which come before MAINICON alphabetically. Changing them to ZIcon_1 and ZIcon_2 resolves the issue so that Windows Explorer takes MAINICON first.

Memory leak in Delphi 'diamond.style' for FireMonkey in Win32. Am I using it correctly?

I've applied the 'diamond.style' from the FireMonkey Premium Styles Pack for RAD Studio XE7 and get a memory leak on closing my app. I am wondering if I am using TStyleBook correctly, although various other styles work fine. This is what I'm doing with a very simple test in XE7 that shows the problem.
Use File | New | Multi-device application (then choose blank application for simplicity).
Set the target platform to Win32.
Drop a TStyleBook on the form and edit the Form's 'stylebook' property to point to this.
To the project source, add: ReportMemoryLeaksOnShutdown := true;
Run the project, it should open and close fine.
Double-click the style book. Click 'load' and nominate the style file "C:\Users\Public\Documents\Embarcadero\Studio\15.0\Styles\Diamond.style".
Click 'Apply and close'
Run the project again. You see the style applied to form and border etc.
When you close it you see a memory leak.
I've played around trying to dispose the stylebook on shutdown etc. but to no avail. Am I using TStyleBook correctly?

can not change Delphi application icon

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.

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

Save dialogue hangs in XE2

I use Delphi XE2 on Windows 8. I have ported an D2009 application to XE2 and suddenly the save dialog (TSaveDialog) is very slow.
When Project/Options/Application/Runtime Themes is set to Enable Runtime Themes:
=>
When I open the save dialog the window freezes for about a minute (sometimes I can close the window but have to wait about a minute until I can open the dialog again (or another TOpenDialog). The new Vista style save dialog is shown.
If I try to run this exe on a PC with Windows 7, the app hangs upon start (I did also try with XP compatibility mode without success).
When Project/Options/Application/Runtime Themes set to none:
=>
Save dialog works well (fast) but the old style dialog is shown, se example below:
This exe works well on a PC with Windows 7 (though with the old style dialog).
Ps. My old exe-file compiled with D2009 on a Win 7 PC works however well on both the Win 7 and 8 PC:s, and shows the dialogs correctly using the new Vista dialog style.
Could it be some permission rights in Win 8/7 causing this? I use IDE FIX PACK 5.4,
Thanks,
Thomas
I found what the problem is. I use {$MAXSTACKSIZE $4000000} and this causes the save dialogue to freeze for about a minute.
The reason for this hefty stack size is that I use a recursive algorithm (that I now probably need to remake).
Reproduce as follows (XE2):
Create a new VCL forms application
Place a TSaveDialog1 on the form
Place a Tbutton with OnClick event
`
Begin
if SaveDialog1.Execute then
MessageDlg('ok', mtInformation,[mbOk], 0);
end;
`
4: Open the project source file and put the following rows:
//{$MAXSTACKSIZE $3500000} //this is a decimal value of 5 5574 528 OK!
{$MAXSTACKSIZE $4000000} //this is a decimal value of 6 7108 864 Not OK!
Run and click the button. Give a dummy file name and press save. Nothing happens. Keep on clicking the button for 60 seconds. The dialogue will finally close.
Change to the smaller stack size $3500000. Now the program works well. Thanks for all tips.

Resources