Wrong EXE Application Icon with Resource files - delphi

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

Related

Visual Studio Professional 2019 version 16.10.0 Can't open .sql files in SSDT project

Upgrade VS 2019 Professional to latest version 16.10.0. Open an existing SSDT project, double-click on any sql script file in the project, the file can't be opened in a tab window.
If the sql script defines a table, I can see the message: The design surface is loading. I can see the separator between design and script surfaces. If I drag the separator to resize the surfaces, the window gets refreshed and the script will open correct.
If the sql script defines a view or stored procedure, I only see blank tab window. i don't see any messages.
If I restart the VS2019, the previous opened scripts are working fine. But still the same problem whenever I want to open a script which is not opened before the restart.
Here's a link to the root Microsoft tacked issue:
https://developercommunity.visualstudio.com/t/Visual-Studio-Pro-16100---Tabs-do-not-/1434964
A quick work around to force the editor to re-draw: resize the editor window by dragging the solution explorer re-size bar.
In VS 2019 Community 16.10, I can open one SQL file at a time. So if you shut all your open SQL files, you should be able to get a single one open.
Note: even uninstalling VS and starting with a clean install from the Microsoft site did not help.
Here's a link to the MS discussion of this topic:
https://developercommunity2.visualstudio.com/t/Cannot-see-content-of-sql-files/1437162?q=%5BVisual+Studio+2019+version+16.10%5D&ftype=problem&space=8&stateGroup=active&sort=newest
I was able to get two SQL windows open at the same time, though it is quite annoying: open both files and detach both from the documents frame so they float. Pick one and move it and size it where you want. The second will disappear as you do this, but never mind.
From the Window menu, select the second file. As you move it and size it, the first one will disappear.
Now select the invisible window from the Window menu. As long as you just move around and work within these two files, you should be able to keep them both open. So this is if you need to be looking at one view while you modify another, or some such thing.
For me, two is the limit. If I try three, only two will be visible.
This was a bug and seems to be fixed in the latest patch 16.10.2 - https://learn.microsoft.com/en-us/visualstudio/releases/2019/release-notes#--visual-studio-2019-version-16102-

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.

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.

Best way to add icon to delphi 2007 app (win7)

I want to add icon to my delphi app. Icon was generated from image via ICOFX, including 128x128 and 256x256 (Vista) icons. I tried to add icon several times:
First of all, using Code Gear IDE: Project Options->Application->Icon. This was an easy way, but Vista-sized icons (128x128 and 256x256) were not added. When scaling in Windows Explorer Ctrl+Wheel, icon stoped increasing in size after 64x64. This happens because Delphi does not support big icons.
Then I tried to change icon in MyProject.RES file (using ResourseExplorer). It did not helped much.
When changing .exe-file icon using ResourseExplorer problems seems to be solved, but this is not a Path of a jedi, obviously. And some problems appears/remains, such as:
when changing .exe-file name (ex: from MEPROG.EXE to _MYPROG.EXE), file icon is changing either (128x128 and 256x256 icons disappeare).
when using MouseRightButton->Send to->Desktop to create a label, label's icon is of small resolution.
copy-pasting exe-file into some other directory(not in deplhi project output dir), could also change icon.
Is there a better way to do this, or I am doing this wrong way?
The Delphi 2007 IDE cannot handle large Vista icons, which use PNG compression. And neither can the brcc32 resource compiler that ships with Delphi 2007.
My solution, when I was still using legacy Delphi versions, was to make a .rc file containing the icons, and compile using the MS resource compiler, rc. The MS resource compiler does support such icons, and is readily available, for example with the Windows SDK.
See the change-log around 2.7 version
http://andy.jgknet.de/blog/ide-tools/ide-fix-pack/
it seems you just try to use Delphi without installing necessary fixes
PS. another way might be to make some command-line utility replacing icon resource and then auto-call it after compilation phase. Still ugly, but better than manually launchign ResEdit each time.
If you do not see the icon, you can just run the following command to clear the icon cache:
ie4uinit.exe -ClearIconCache
For Windows 10, use:
ie4uinit.exe -show

How do I add recent items to my program's jump list on the Windows 7 taskbar?

I'm using Delphi XE and would like to add "recent items" in the Windows 7 taskbar jump list for my application, like when right-clicking on Microsoft Word brings up recently opened documents.
I've found information on how to set the progress but nothing on jump-list items. Any help would be greatly appreciated.
This will happen automatically if, for instance, you only use the standard Windows file dialogs. At least my text editor, Rejbrand Text Editor, has got such a MRU list by Windows. It lists all files I have recently edited using Rejbrand Text Editor, even though I have not written any code at all for it.
I think that Windows observes the files you
open and save in your application by means of standard Windows file dialogs
open in your application by starting yourapp.exe <file name>, for instance by double-clicking a file that opens in your application
and automatically display these in the list.
If you want to control the task bar button and menu programmatically, you can use the Windows API. Delphi-specific examples are found in this blog post.
In my opinion the best way to do this is to make the following simple API call:
SHAddToRecentDocs(SHARD_PATH, PChar(FileName));
This not only deals with Windows 7 jump lists but also adds your file into the system's list of recently used documents which has an effect on early versions of Windows too.
Call the function whenever you open or save a file.
For your convenience, a link to the documentation of SHAddToRecentDocs().
Here are some resources that I have found useful when making my programs vista ready
http://code.google.com/p/theunknownones/wiki/TaskbarListComponents
http://www.installationexcellence.com/articles/VistaWithDelphi/Index.html
http://www.theabsolute.net/sware/delphivista.html

Resources