Theming Windows applications in Delphi 2007

With the release of Delphi 2007 we’ve made it really simple to theme VCL applications using a checkbox option. On the Project Options dialog, on the Application page you’ll now see the “Enable runtime themes” checkbox which makes the necessary modifications to the projects (.res) resource file to ensure that your application is themed. By default, this option is checked for new Delphi VCL application and as I’ve indicated previously it controls how the designer renders your controls at design time.

Additionally, it’s no longer necessary to include either the TXPManifest component nor the XPMan unit (which is basically what dropping the TXPManifest component did) in your application. In fact, this method of theming your application will likely be deprecated in a future release of Delphi.

Be aware, theming your application may not be a quick and simple operation depending on the use of custom components that either you’ve written or are using. Not all components behave properly when themed so be sure to test your applications if you decide to check this option. You should also be aware of the performance impact that themes have on applications and test accordingly.

[UPDATED: Mar 21, 2007] Clarify that this option is check by default for new VCL applications. For existing applications you’ll need to set this manually. Add information about the resource that’s added to the .res file.

The resource that’s added to is called a “Manifest Resource” which you can learn more about here. Below is a copy of the manifest resource added to a new VCL project which, btw I highlighted using my online syntax highlighter.

1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 2 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 3 <assemblyIdentity 4 type="win32" 5 name="CodeGear RAD Studio" 6 version="11.0.2597.23844" 7 processorArchitecture="*"/> 8 <dependency> 9 <dependentAssembly> 10 <assemblyIdentity 11 type="win32" 12 name="Microsoft.Windows.Common-Controls" 13 version="" 14 publicKeyToken="6595b64144ccf1df" 15 language="*" 16 processorArchitecture="*"/> 17 </dependentAssembly> 18 </dependency> 19 </assembly>

11 thoughts on “Theming Windows applications in Delphi 2007

  1. Can you share with us what, exactly, enabling theming does to the resource file?
    I ask because I generate my RES file at build time from an RC file. We started doing this awhile ago because RES files are a pain when dealing with version control and it’s easier to have a script update the RC file in an automated build scenario.
    I’d like to make the needed changes to the RC files by hand so they match what Delphi 2007 would spit out.

  2. Hi Shawn,
    I’ve updated this entry with details so you can add this info to your RC file. The IDE reads the .res file to determine if the VCL designer should appear themed.

  3. What happens if I have a RES file linked in with $R which also contains a manifest? Which one will take precedence? Given that there are relevant UAC settings in the manifest (which made it into the 2007 version of the one linked in by XPMan, but apparently not into the one that you’re quoting as being the result of the new "Enable runtime themes" feature?!)

  4. If the .res file contains a resource type "24" with ID 1 and it’s a XML manifest then you should be fine. If you toggle the "Enable runtime themes" option then it will change your .res file. I haven’t compared the resource that’s included with the one from XPMan so what you’re seeing may be an issue which you should log in QC. I didn’t code this feature so I’m not sure if what you’re seeing is correct or not. I’ll check…

  5. Thanks for the info. In fact, it seems to be a "feature", not an issue. My RC file referencing the manifest doesn’t contain any language specification, so Delphi compiles it to type "24" ID 1 [neutral]. The manifest from the IDE is "24" ID 1 [US English] and therefore the resource linker doesn’t "produce" a collision. Nasty. Who knows which one of the two Windows will prefer…
    What is probably worth a QC is that the version info that goes into the .RES seems to come from the .DPROJ, while the IDE’s manifest’s one and only location is the .RES file (same for the main icon). This is what you need to have for your version control make sense…

  6. Hi Steve, is it possible to customize the manifest included in the exe? I want to specify a different elevation in the manifest, here are the two options I see:
    -Enable Runtime Themes, enables design time view of themes, the manifest is pulled from bds.exe, not editable.
    -Create my own res and link it with $R, the manifest is fully customizable but the themes can’t be used at design time.
    is there another option?

  7. Hi Alex,
    No, I don’t think you can modify the included manifest though you should make a feature request via QualityCentral to CodeGear (if it hasn’t been done already). I haven’t used Delphi in nearly a year so I’m sure much has changed.

  8. Hi!
    I have the following problem: i have a project developed in 2007 and the application used to have an icon, that i defined. Then, i add more small modules from other singular applications to the application and, the icon, simply doesn’t show, that is, it shows a different icon application from the one i define in my project options.
    I opened the resource file with a tool (Xn Resource Editor), and there appears a Icon Group with the following icons, in this sorting order:
    The icon associated with my application appears at FAVFOLD(with a wrong icon), and the one i define in the Project Options, is in MAINICON. If i delete FAVFOLD, then my application shows the true icon. But, everytime i compile the project, it creates a new resource file with the favfold icon.
    What should i do, to create the correct icon, without using this outside tool?
    I would appreciate any help you may give.
    Thank you in advance.

Comments are closed.