About/Contact

Steve Trefethen

Steve Trefethen is CTO at Wanderful Media.
Contact me

View my LinkedIn profile



Calendar

<<  June 2013  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Disclaimer

The posts on this weblog are provided AS IS with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.



Theming Windows applications in Delphi 2007

March 21 2007 2:41PM
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="6.0.0.0" 14 publicKeyToken="6595b64144ccf1df" 15 language="*" 16 processorArchitecture="*"/> 17 </dependentAssembly> 18 </dependency> 19 </assembly>
FacebookDel.icio.usDigg It!

Comments (11) -

3/21/2007 8:29:54 PM #

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.

Shawn Oster

3/21/2007 9:18:36 PM #

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.

Steve Trefethen

3/21/2007 10:07:40 PM #

Rock star!  Thanks for the quick response.

Shawn Oster

3/22/2007 12:51:07 PM #

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?!)

Thomas

3/23/2007 5:55:35 AM #

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...

Steve Trefethen

3/24/2007 2:41:05 PM #

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...

Thomas

3/24/2007 3:06:05 PM #

Thomas,
  Please get that logged in QC for review. Thanks!

Steve Trefethen

6/20/2008 9:43:12 AM #

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?

Thanks,

Alex

Alex

6/20/2008 3:56:19 PM #

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.

Steve Trefethen

9/19/2008 10:32:30 AM #

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:
- FAVFOLD
- MAINICON
- NEWFOLD
etc
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.
Ana

Ana Maria

9/19/2008 3:21:42 PM #

Ana,
  I'd suggest posting this issue to the CodeGear newsgroups. You may be running into a bug.

Steve Trefethen

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading