Tuesday, May 06, 2008

Dealing with the Duplicate Resource: Type 24 when enabling theme support in Delphi 2007

I was writing a little utility in Delphi 2007 to make it easy to work with data stored as the XML data type in SQL Server. While I have been using Delphi 2007 since it was released last fall, this was the first desktop app that I had written from scratch. I threw some components up on the form and I did a quick compile to see how the visual elements looked at runtime. I got the following error message:

[DCC Error] E2161 Warning: Duplicate resource: Type 24 (user-defined), ID 1; File C:\dev\RawDataQuery\RawDataQuery.res resource kept; file c:\program files\codegear\rad studio\5.0\lib\WindowsXP.res resource discarded.

I was dragging and dropping components from an app that I had originally written in Delphi 7 and one of the components was a TXPManifest component. The TXPManifest is component that only appears at designtime. When your code is compiled, it includes the WindowsXP.res resource file, which contains the manifest resource needed to enable XP style themes. In Delphi 2007, you can enable theme support in the project options. It's a checkbox labeled "Enable runtime themes" on the Application page of the Project Options dialog.

You can't have both "Enable runtime themes" checked and an instance of TXPManifest in your application. They both try to pull in WindowsXP.res and the second attempt will FAIL. The fix for this is easy. You can disable the "Enable runtime themes" setting or remove the TXPManifest component from your form and remove the reference to xpman in that form's uses clause.

My personal preference is to remove the component and unit references and just use the project setting. When there are two methods of doing the same thing, I tend to pick the simpler solution. The fewer the number of moving parts, the less likely it is for something to break.


  1. Thank you very much. I too am just starting to work with 2007 and did the same thing.

  2. Very nice post... keep writing...

  3. Hi chris ... I'm trying to remove as you said.

    One of option Enable runtime themes is uncheck.

    But still no luck, with error : Unable to create process.

    How to resolve that

  4. Chris,

    Your post saved me a lot of troubleshooting. thanks for taking time to offer a bit of help.

  5. Since this deals with Themed Apps in Delphi 2007, just wondering if by chance you've experienced any problems with Themes Enabled. For instance, in using TDBNavigator with 'Flat' set to true, navigator buttons don't remain flat as they should but do if I uncheck Enable Themes in my project file. Any thoughts on this?

  6. Anonymous,

    It's been years since I used the TDBNavigator component, I don't know how it behaves with themes enabled. You may want to check the Delphi newsgroups to see if anyone else had this problem.

  7. Hey!

    thanks for postings this. You rescued my morning.
    Greetings from Germany!

  8. Greetings from Russia also!

  9. Yes, simpler is better.

    But when it's "dumbed-down" too far (like a single button, or in this case check-box), then it's not always so cool...

    The dumbed-down option in this case means your manifest is on *OR* off - no variation!
    The problem being that it is on according to Code Gear spec, with **no flexibility**. If you want your manifest to specifiy access levels, you cannot use the _only option provided_. You'll need to roll your own, and uncheck the single button option.

    Unfortunately, unchecking the option means you cannot see the new styles in your form designers.... so you're caught in a catch-22.


Note: Only a member of this blog may post a comment.