I am coding a Windows GUI Application in CB. I can compile my program perfectly. Problem is that I need to add a custom icon and version information in it.
As CodeBlocks has not a resource editor I had to do it myself. But it doesn't work. I checked numerous threads and the Code Blocks FAQ, but nothing solved my problems.
The files in my project root are main.cpp, resource.rc, icon.ico, theprogram.cbp, theprogram.layout
My program in main.cpp
#include <windows.h>
#include "resource.rc" //I indeed include resource.rc
...winmain, winproc etc.
resource.rc
#include <windows.h> // include for version info constants
//ICON
A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "icon.ico"
//VERSIONINFO
1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
{
BLOCK "080904E4"
{
VALUE "CompanyName", ""
VALUE "FileVersion", ""
VALUE "FileDescription", "testing the description"
VALUE "InternalName", ""
VALUE "LegalCopyright", ""
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", ""
VALUE "ProductName", ""
VALUE "ProductVersion", ""
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0809, 1252
}
}
The Compiler stops in
C:\CPP Projects\theprogram\resource.rc|7|error: `A' does not name a type|
||=== Build finished: 1 errors, 0 warnings ===|
Any help? Thanks in advance.
Yes, but I could use some extra help, that's why I posted in this forum?
Nevertheless I found a solution, I'll leave it here in case someone else needs it.
In your main.cpp file add the line:
#include <winver.h>
Place your icon "myiconfilename.ico" file inside the project folder.
Create a new file in the project folder called resources.rc, and write into it
#define VOS_NT_WINDOWS32 0x00040004L
#define VFT_APP 0x00000001L
//this will set your .exe icon
A ICON MOVEABLE PURE LOADONCALL DISCARDABLE "myiconfilename.ico"
//include version information in .exe, modify these values to match your needs
1 VERSIONINFO
FILEVERSION 0,1,1,1
PRODUCTVERSION 0,1,1,1
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "CompanyName", "write version info here"
VALUE "FileVersion", "write version info here"
VALUE "FileDescription", "write version info here"
VALUE "InternalName", "write version info here"
VALUE "LegalCopyright", "write version info here"
VALUE "LegalTrademarks", "write version info here"
VALUE "OriginalFilename", "write version info here"
VALUE "ProductName", "write version info here"
VALUE "ProductVersion", "write version info here"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409, 1252 //language codes
}
}
finally ADD the resources.rc and the icon in the CodeBlocks IDE by right clicking on the Management and selecting "Add Files..."
You're done!
Also if you want your controls (buttons, checkboxes etc.) to support modern Windows XP and Vista styles,
you must write a new file called "xp.manifest" and place it in the project folder as well, the file will contain an xml structure:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
name="Exe.Apps.Project"
processorArchitecture="x86"
version="1.0.0.0"
type="win32"/>
<description>Project</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Then update your resources.rc file with the line:
There you go. :)
I also suggest you update your F.A.Q. since it didn't provide enough info to solve my problem, let alone for other more inexperienced users.