Question

I`m using Delphi XE3. When using the custom styles (e.g. Carbon) that are available since Delphi XE2, there is a visible white flickering when moving the mouse over the borders of the TComboBoxEx control (MouseExit/Enter).

Steps to reproduce: Create a new VCL Forms app, drop a TComboBoxEx on the form, select e.g. Carbon in project options --> Application\Appearance and start the application

Is this a known problem/bug and is any solution known?

Thank you

Was it helpful?

Solution

This Border flicker issue is not the product of using Delphi VCL Styles.
(The same problem can be observed without using VCL styles)

The culprit here is the Desktop Window Manager which is an essential part of
Windows Visual Styles and Themes.

The reason why you are seeing this issue and others may not, is because you have at some point changed the default Windows Theme (aero theme) or you've changed a specific Visual effect property of your selected theme.

You perhaps also have intentionally or unintentionally disabled the Desktop Window Manager since it runs as a Windows service.

To be more exact, the issue is resolved if you enable the Desktop composition feature.
This feature is only available in Aero themes(default) but not in Basic or Classic, tho sometimes it can appear to be available even when it is not.

Control Panel --> System --> Advanced System Settings --> Advanced --> Performance Settings --> Visual Effects

enter image description here


When desktop composition is enabled, individual windows no longer draw directly to the screen or primary display device as they did in previous versions of Windows. Instead, their drawing is redirected to off-screen surfaces in video memory, which are then rendered into a desktop image and presented on the display.

As you might have guessed, the functionality of this function is to basically act as a Buffer
which in a very neat way explains the border flickering when this option is turned off.

Important Fact

Desktop composition feature can only be enabled if your current theme is an Aero theme and using Windows Visual Styles.(It is by default enabled for every Aero Theme)

Visual Styles are enabled by default in Aero Themes, you can check that it is enabled by making sure that the Use Visual Styles on Windows feature is enabled in the Performance Settings. When the Classic or Basic Themes are in effect the desktop composition feature is never in play and cannot be enabled. (Classic theme has been deprecated since Windows 8)

Sometimes in Windows 7, the Desktop composition feature can show itself in the Performance Options even when using a Basic or Classic Theme but do not be fooled, this is an internal bug.

Steps to reproduce this bug :

  1. Start With default Windows Aero Theme
  2. Go into Performance Settings as described above
  3. Uncheck the Desktop composition from the list
  4. Mouse over the border of TComboBoxEx, it should now be flickering as you enter/leave.

But what happens if I uncheck Use Visual Styles on Windows checkbox? Why does this solve the flickering issue?

This will cause the Desktop Window Manager(DWM) to disable themes all together for all Windows Controls. What this means is that controls will be drawn using an older rendering style as oppose to using the newer Aero rendering style.

You can turn off Visual Styles for individual controls without turning it off globally with the following method SetWindowTheme(Handle, nil, nil)

This is also why the flickering issue for TComboBoxEx border is resolved when Visual Styles are disabled. It's also worth mentioning that since Windows 8 you cannot disable Visual Styles anymore because as I said the Classic theme is deprecated.


Regarding the solution, I don't think you've got much of a choice really. Given how much freedom is left to the user when it comes to modifying the visual effects of Windows themes, this sort of thing is bound to happen. At least you can be certain that this issue does not happen on the default Windows Theme.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top