JackTrapper / DelphiBugs

Bug tracker for Delphi
7 stars 2 forks source link

TUxThemeStyle.GetEnabled returns false when themes are available and enabled #17

Open JackTrapper opened 5 years ago

JackTrapper commented 5 years ago

Tested

Background

The TUxThemeStyle.GetEnabled function (Like Mike Lichke's code it came from) misktanely thinks that using Version 6 of the ComCtrl32.dll is related to themes being enabled.

The ability to use Visual Styles is independant of whether we are using version 6 of the Common Controls library:

The correct way to not use visual styles in the application is to add an entry to your application's manifest:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
            ...
   <asmv3:application>
      <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
          <disableTheming>true</disableTheming>
      </asmv3:windowsSettings>
   </asmv3:application>
   ...
</assembly>

tl;dr: Theming enabled is what determines if themes are enabled. Theming is still enabled even if i'm using CommonControlsV5.

The Fix

Vcl.Themes.pas:

function TUxThemeStyle.GetEnabled: Boolean;
begin
   //WRONG:
   //Result := FAvailable and FUseThemes and FNewComCtrls;

   Result := FAvailable and FUseThemes; // and FNewComCtrls; themes being enabled has nothing to do with the use of new common controls. 
end;