3

In a legacy application (created in Delphi 6 under WinXP in 32-bit, recently ported to Delphi XE2 under Win7 in 64-bit) at design time, the standard controls look "modern", with color gradients etc. In run-time though, they look just like an old Win95 version.

That would not bother me much if, in particular, the default colors in TPageControl and TTabControl wouldn't make it really difficult to tell which tab is currently selected.

So my questions are:

  1. What could make the theme not active at run time?
  2. Is it possible to easily (e.g. through IDE configuration) make the design time look like the run time?

Note:

  • In the project options, I enabled runtime themes for each existing target. It didn't help.
  • I also tried to enable GlassFrame in the forms containing those controls. Unfortunately, the runtime look and feel stayed unthemed.
  • This application is built on a lot of in-house and external code that I don't master (just a dwarf standing on shoulders of giants), but whose source are available to me. Suspecting that some instruction would disable themes at application startup, I looked for some keywords like "Theme", "Skin", "TStyleManager", "SetWindowTheme" hoping to solve this by myself. I could not find anything significant (to me, at least).
  • I tried to skin a small application as a test, using infos from Question Delphi XE2 VCL styles tutorial - how to change the style at runtime, and it worked perfectly.
  • Skinning my application is not my goal. I just would like to be able to visually tune some GUI elements at design time, and it is easier if design and run time look alike.
Community
  • 1
  • 1
Papaya
  • 332
  • 3
  • 15

2 Answers2

6

It turns out that removing the line "{$R *.res}" in the dpr file had made the themes unavailable.

Under D6, I disabled version information in the project and replaced "{$R *.res}" with "{$R 'myApp.res' 'myApp.rc'}", to use my own rc file to have the version information in a separate, easy to edit file, and not to be forced to go through the project options.

Under XE2, that did not work anymore because the resource would often be overwritten (or not taken into account, I'm not quite sure) by Delphi during the build. I had to rename the rc file so that it does not match the application name, thus replacing "{$R 'myApp.res' 'myApp.rc'}" with "{$R 'myApp_rc.res' 'myApp_rc.rc'}".

Putting the "{$R *.res}" again (along with "{$R 'myApp.res' 'myApp.rc'}") seems to make things right with themes and not break the version information.

Thank you Brian for having me look in the good direction.

Papaya
  • 332
  • 3
  • 15
1

In my experience this is often due to project differences between DEBUG mode (used by default when in the IDE) and RELEASE mode. Open your project options and scroll to application (where themes styles and icon are defined). Notice that the platform and build option combo at the top holds separate values for each setting and I expect you will find that your DEBUG build config has runtime themes enabled but RELEASE does not.

Brian Frost
  • 13,334
  • 11
  • 80
  • 154
  • As I tried to express in the first note of my question, I already checked that each target (i.e. "All configurations", "Debug configuration", "Release configuration", each time for both "32-bit Windows platform" and "64-bit Windows platform") has runtime themes enabled. I checked again after reading your answer to be sure, but it definitely does not help in my case. – Papaya Jun 25 '12 at 11:18
  • Ok.. You could also try turning on version information for your release project -this may show up something. Enter a version number of non default and confirm that it appears using explorers file properties 'details' tab. – Brian Frost Jun 26 '12 at 12:31
  • What should I be specifically looking for? I ask this because I use an RC file for version information (a line like "{$R 'myApp_rc.res' 'myApp_rc.rc'}" in myApp.dpr, just after "program myApp;"), and most of the fields that I filled in the RC appear in explorer's file properties. Should I try to use "automatic IDE version information" anyway, just to see? – Papaya Jun 26 '12 at 13:00