How to get multiple icon file into Delphi resource file - delphi

I'm trying to generate a multi-size icon file to my Delphi app, so Windows will choose the best size to show in each situation.
Following the official support instructions at https://docwiki.embarcadero.com/RADStudio/Sydney/en/Creating_and_Deploying_App_Icons
Storing Your Icon Files into an Icon Container
Once you have your app
icon in all the resolutions that a target platform requires, for
desktop platforms you must then archive the different resolutions of
your icon into a single file, an icon container, that you can deploy
along with your application.
For Windows, you must create an .ico icon container file. See How to
make/get a multi size .ico file?."
It directs to this Stack Overflow question :
How to make/get a multi size .ico file?
I followed the instructions exactly as described and could get a multi-size icon file using ImageMagick.
Problem is , when i try to compile my resource file using BRCC32, i get this error :
[BRCC32 Error] icon.rc(2): Allocate failed
Here is the contents of my RC file :
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
MAINICON icon "myapp.ico"
If i go to Project > Application > Icons, i can load the myapp.ico without problems, but due to the nature of my project, i need to use a resource file instead.
Please help, i'm stuck on this issue for days.
Thanks

From the documentation on resource compilers:
Both C++Builder and Delphi give you a choice of resource compilers. On the Project > Options > Resource Compiler dialog box, you can select either of the following:
BRCC32.exe, the C++Builder resource compiler
RC.exe, the Microsoft platform SDK Resource Compiler
RC supports Unicode characters in resource files and file names, as well as new Vista resource types such as icons with alpha channel.
Hence, if you need Vista icons, you need to change to the RC compiler.

Related

Executable File in Xcode 6

I finished creating a basic mobile app on Xcode and I want to be able to generate an executable file (much like a jar executable) that has compiled all my related files and can launch my app on another computer without Xcode. I've looked at other resources online that have directed me to the picture below and I think the highlighted file is my executable (correct me if I'm wrong) but when I double click it I get an alert telling me that "this application is not supported on this type of Mac".
Any insight on how I can generate an executable or find one automatically generated by Xcode would be helpful. Thanks in advance!

Cannot link the icon resource

I try to add an icon in my Delphi 5 project and compile/link it, but get the following error:
"[Error] RLINK32: Out of memory!"
What is the problem?
The icon is at http://www.shuling.net/temp/Project2.zip
Your icons include large style 256px icons that were introduced in the Vista time frame. The Delphi 5 tooling is incapable of linking them. As I recall, the brcc32 from Delphi 5 cannot handle these icons because 256px icons are represented in a .ico file as having size 0. They are also stored with PNG compression to keep the size manageable. The brcc32 from Delphi 5 knows nothing of this and simply cannot handle it.
When I was linking such icons to my old Delphi 6 projects I used the Microsoft resource compiler, rc.exe to compile the resources. The Delphi linker from Delphi 6 was able to link the compiled .res files.
I'm not sure whether or not the Delphi 5 linker will be able to do even that. If not then you will need a post-build action to link the resource to the file. However, if I recall correctly, all I had to do was use rc.exe to compile the .rc file to .res, and then let Delphi link that.
So, in summary you need to:
Compile the .rc file with a modern resource compiler, for example rc.exe.
Link the resulting .res file in the usual way with $R if Delphi 5 can do so. If it cannot, use a separate post-build too to link the .res file.

Get apk file icon, version, name in delphi

Is there a way I can get application name, application version and application icon, for the package that is not yet installed by delphi?
*.apk files are basically zip files, so you can have a look at the single resources at least to get the app icon. The ApplicationManifest.xml is howewer compiled into some binary format, so this might be a bit harder to decode (but there are answers that show code for that task as well here: How to parse the AndroidManifest.xml file inside an .apk package).

Best way to make a component icon in Delphi XE using only the built in tools

In Delphi 7, an image editor program is included, which can read and write .dcr files, which are merely binary resource files (.res files) with a different extension, which by convention indicates that the .dcr file contains a compiled resource with named bitmap resources that have names corresponding to your component names (a bitmap resource named TMYCOMPONENT for a component named TMyComponent). These bitmaps are where the "icons" used to put an icon on the delphi component palette, and on your form or data-module when you drop a non-visual component on it, come from.
Fast forward 10 years to Delphi XE, and I am trying to make component icons using a bitmap file, and an RC file, and have that build to a .DCR file, as part of the Delphi IDE.
It should be simply a matter of adding an .Rc file and a declaration like this in the .dpk (package source) file, like this:
{$R mypackageicons.rc mypackageicons.dcr}
A sample .rc file containing a component icon:
// COMPONENT ICON RESOURCES
TMYCOMPONENT BMP "TMYCOMPONENT.BMP"
However I can not get this to work. It seems that you get some bizarre RLINK32 errors, and IDE crashes in borlandmm.dll, when I try it:
[DCC Error] E2161 Error: RLINK32: Unsupported 16bit resource in file "C:\temp\compicon\COMPONENTICONS.rc"
[DCC Fatal Error] F2084 Internal Error: AV21515155-W06000D07-1
The bitmap file in question is a simple 256 color bmp file size 24x24 pixels, and I have also tried 16 color bitmaps, with no luck. It seems to me that the ImageEdit program is the only way that I know of that I can use to create Delphi component icons.
What am I missing out on?
Update: The external tools are a nice solution for people who don't have access to the Delphi 7 image editor, and may in fact be superior, but I would prefer to do this using only what ships with Delphi, because it seems that it should be possible using just one {$R} declaration, a text file, and a bmp file made with paintbrush. Surely they didn't omit to make a way to make component icons, with this great big 1.5 gigabyte developer tool! .. update2: And there is a way; Rudy V. found it.
I have used and had great success with:
Colin Wilson's XN Resource Editor
Anders Melander's Resource Editor
Update
I just tried the following, in XE, and was successful.
I created a new component, TNewAnimate, in NewAnimates.pas.
I added TNewAnimate.pas to dclusr.dpk.
I added a bitmap (called TMRUComboBox.bmp, I just had that around anyway) using the Project → Resources and Images... dialog to the .dpk and gave it the name TNEWANIMATE.
I re-installed dclusr.dpk.
The source file for dclusr.pdk got a new entry {$R *.dres} (note the extension). I could see the TNewAnimate in the Samples palette with the glyph in TMRUComboBox.bmp.
I located dclusr.dres in the same directory as dclusr.dpk (which is normally under C:\Program Files, but not in my setup). I tried to open it with XN Resource Editor, but that refused to open it with a cryptic error message. It is not a normal .res file, it seems.
Try Resource Editor. A nice replacement for old Image Editor.
First add 'mypackageicons.rc' file to the project, this produces 'mypackageicons.res' at compile time (see related SO answer to the question "Including resource file in a project by .RC file rather than .RES file").
Also include {$R mypackageicons.res mypackageicons.dcr} to the component unit (or to the .dpk). This does not produce a '.dcr file', but sets the icon for the component.
Note that my test with a 'BMP' resource failed. I used 'BITMAP' as resource type.
I have investigated the previous responses using Delphi XE5 upd2. Not much success. So I tried to build a new solution and found one derived from previous answers.
In short:
1. Create your bitmap using Windows Paint program.
2. Create a resource script file with the bitmap.
3. Compile the script with BRCC32 to produce the dcr file
4. Include the dcr file into the package source
5. Recompile/Install the package
To automate this, it is enough to add the BRCC32 command line into the package project "pre-build events". This way, you dcr file will be recreated before each build.
For a detailed description, see my blog at http://francois-piette.blogspot.be/2014/02/howto-create-dcr-file-for-your-delphi.html

Is there a way to change the default EXE icon in 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

Resources