Is there a way to change the default EXE icon in Delphi - delphi

Embarcadero just released a whole bunch of neat looking icons that I'd like to use to make my Delphi 7 and 2009 apps look fancier. Is there a setting (or hack) in those IDEs that lets me change the default exe icon?

You could always use a resource editor to find the icon in the Delphi ide or bpl and change it to something else. That would be permanent for all new projects.

Apart from the fact that Andrey answered exactly what you asked I assume you want to add more icons to your executable than just the one you can set in the project option? This can be done by adding a *.rc file to the project. The following line should go into your project:
{$R 'Icons.res' 'Icons.rc'}
The rc file is a plain text file that Delphi compiles into a res. To the rc file add 1 icon per line like this:
XIcon01 ICON ".\Images\ico\ADDRESS2.ico"
XIcon02 ICON ".\Images\ico\ADDRESS3.ico"
XIcon03 ICON ".\Images\ico\ADDRESS4.ico"
The first part is the name of the icon. I chose names that come after Mainicon alphabetically with Mainicon being the icon that you define in the project options. I'm not sure (maybe somebody can confirm?) but I think that Delphi compiles the first icon as the application icon so I made sure my additional icons sort later.
In case you want to change the application's icon at runtime you can use the 2 Application.Icon.LoadFromResource routines.
Hope that helps

Related

Delphi - Icon of compiled EXE is wrong and cannot be changed

I'm having this strange issue for the first time in my 15+ experience of using Delphi.
This is the icon I set in the project options (XE4):
And this is the resulting application icon after compiled:
I've no idea where does that icon come from and I have no way to change the icon (really driving me crazy).
The icon of this project has been ok for over a year until later today. Things I've tried with no luck:
Use the 'Load Icon...' button to change it to another complete different icon and re-build.
Use the 'Default' button to reset to default icon and re-build.
Deleted project1.res file and re-build.
Deleted the .dproj file, open .dpr file instead and let the Delphi IDE created a blank new .dproj file. no luck.
I thought it's the Windows 7's IconCache.db file corrupted, deleted that file and restarted Windows, no help. Actually I used Resource Hacker to confirmed it's not the Windows Explorer displaying the wrong icon but it's the icon resource in the EXE is wrong... too strange.
restored the .dproj file from SVN to yesterday(the icon was ok yesterday)'s revision and no luck.
Anything else do you suggest me to try? Thank you!
Review the line in your main form with {$R *.res}. I had the same issue and it was that this line was accidentally deleted. That caused that icon and other resouces to not be correct in the final executable, like version number, icons etc.
If you don't know what that line is, simply make a few empty new vcl application and search it in the main form.

Version Info in Delphi 7 not working

I was assigned to make a small modification in a Delphi project.
To register that mod, my boss told me to increment the build number in Project options > Version Info.
I did that, but after compiling and building, when I look at the file properties, file version is not updated. The exe file was indeed compiled (I checked the modification date and it matches the time of build). The version number in the final EXE is unchanged, and not equal to the number I set in Version Info tab.
When I search Google about this, the only results I could find was tutorials to use this version feature and people with problems enabling it.
I tried reopening the project, deleting the generated EXE and rebuilding, removed the .RES file (the build fails because there's no RES file) and commented out the {$R *.RES} directive (no Version Info is included at all).
I'm not the original developer of this project, and the original one is not available anymore.
I think this could be related to this post, but it is from another Delphi version, and I couldn't find a dproj file in my project.
So, anyone knows whats wrong? Is it some kind of bug or am I missing something? Is there another option I should change so this option takes effect?
Use build instead of compile... it have no shortcut, you find it in Project menu (under compile)

Why won't Delphi XE2 let me embed a font resource as RCDATA?

I would like to embed a .ttf font resource into my EXE and dynamically load it. This particular method expects the resource to be of type RCDATA. So, I go to Project > Resources and Images... press Add..., and pick my .ttf file. The resource type FONT is automatically selected with an identifier of just 1. I change the type to to RCDATA and type in my own resource name.
Problem: When I press Ok I get an error that the identifier of a FONT resource must be a numeric value. But it wasn't FONT type anymore, I had changed it to RCDATA.
How do I get past this problem?
(asking and answering together because I'm sure others have seen this problem)
It seems to be just a small bug in the IDE. When you first select your .ttf file in this resource screen, change the type, press Ok without changing the identifier (leave it 1). Then, open the same screen back up, change the identifier to your own, and press Ok. It only works if you close and re-open the Resources and Images screen.
You could of course also write your own .rc file and do everything manually without this screen.
Unlike Jerry says, you can simply "load" the font file in the Resources and Images... dialog. Once you selected it, you can change the type to RCDATA (combobox an the lower right) and if you have done that, you can change the name to whatever valid name you choose.
There is no need to close and re-open the dialog.
I tried this in XE2 and in XE7, and it works as expected. The FONT type is merely the default for, well, font files. That can easily be changed in the dialog.
This doesn't look like a bug to me. Just plain default behaviour when you load a font file. Just like there is default behaviour when you load a .pas file in the editor.
If you want to use an .rc file, it is quite easy to generate one in the editor (new text file with extension .rc) and then you can add it to your project. The IDE will take care of the rest. No need to do anything manually there either, except of course editing the .rc file.

Where is the Deployement Screen

I am trying to keep my application in the background on the iOS platform using firemonkey.
I have came across an answer witch tells me how to make the application remain in background.
Here is the answer:
You'll need to copy the info.plist file and modify it using a unix EOL
friendly editor (such as Notepad++). Add the following lines to it:
UIBackgroundModes voip
In the Deployment screen for your project, uncheck the original
.info.plist, and add the copy you modified. Note that if you
change any project options that changes the original, you'll need to
go thru this process again, or just reflect the changes in the
modified file.
How ever I can't figure out where is the Deployment screen. Does anybody know ?
(NOTE: I don't do iOS development, so this info is based on some quick experimentation with a new iOS FMX project in XE5.)
Those instructions are for XCode, which isn't Delphi. Delphi doesn't have the XCode deployment screen.
The Delphi equivalent is in Project->Deployment from the IDE main menu. You can locate the .plist file in the Local Name column, in the form YourProject.info.plist. I think the original copy is actually generated when you build your project for deployment (either Release or Debug) to the simulator or device, so you may have to do that first in order to find it.
If you look at the samples for XE5 (which seems to be the one in Samples\Delphi\DataSnap\connectors\iOSClients\client_company_tweet), you can see where they're located once the file has been generated.

Dynamic file type icon

I want to register a file type in windows and make a program with Delphi to draw the icon of file according to its contents (something like a custom icon format). How can I do this?
Thanks to Nortd and user539484 comments, I searched the internet for "shell icon handler Delphi" and found a good sample here, and also Shell+ components has a component to do this.

Resources