Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TDateTimePicker VCL Styles glitch in XE2 that only happens on Windows Classic Theme

I guess this is yet another reason why VCL styles are not ready to be really used.

TDateTimePicker control looks fine without VCL styles. Turn on any vcl style, and I get this appearance:

enter image description here

I can turn off the vcl styles for just this component type, by registering a style hook, but that looks really ugly.

This is on Delphi XE2 with update 4 installed.

Ideally, I hope there is a workaround, or some properties of the datetime picker, or some subclass of datetimepicker I could do to force the datetime picker to paint and theme correctly.

Note that normal comboboxes are theming correctly. Note that this reproduces easily in the most minimal sample project imaginable. Yes. It's Yet Another Styles bug.

Update It might be platform specific, related to Windows Common Controls versions on Windows Server 2008 R2 without Aero ("Desktop Experience" in Windows server component terms). It just occurred to me after other people cannot reproduce it, to try this on several different Windows machines. After I did that, I find that the problem only reproduces on Windows Server 2008 R2. Some of our customers use Windows Server 2008 R2. As you know a major reason for using VCL Styles is that it makes your app look the same regardless of what the windows theme is. However in the case above, the whole app themes properly, except the DateTimePicker control, which is themed incorrectly, and only on Windows Server 2008 R2. The same XE2-based demo app works fine on Windows 7.

Both the working and non-working systems have a ComCtl32.dll in the SysWow64 folder with version reading 5.82.7601.17514. However, clearly the native layout and appearance of these controls is different, when VCL themes are off, and this affects the skinning code, which fails.

Update2: Reported as a bug: QC Entry 106783

like image 663
Warren P Avatar asked Jun 27 '12 15:06

Warren P


1 Answers

Ok, I just made a small change to the Vcl.Styles.DateTimePickers unit which is part of the vcl-styles-utils. To fix this issue when the "Windows Classic" theme is active.

Use this style hook in this way

uses
  Vcl.Styles,
  Vcl.Themes,
  Vcl.Styles.DateTimePickers;

initialization
 TStyleManager.Engine.RegisterStyleHook(TDateTimePicker, TDateTimePickerStyleHookFix);

And this will be the result.

enter image description here

like image 175
RRUZ Avatar answered Oct 15 '22 18:10

RRUZ