-
-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
… and later. \o/
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,11 +44,13 @@ | |
{ } | ||
{******************************************************************************} | ||
|
||
{ Simplified by Martijn Laan for Inno Setup } | ||
{ Simplified by Martijn Laan for Inno Setup | ||
{ Cannot be replaced by Delphi's built in Winapi.UxTheme.pas even though it has | ||
Cannot be replaced by Delphi's built in Winapi.UxTheme.pas even though it has | ||
the same functions: see the comment at the bottom of this file. For this | ||
reason this unit has been renamed to NewUxTheme. } | ||
reason this unit has been renamed to NewUxTheme. | ||
Additionally this unit includes SetPreferredAppMode. } | ||
|
||
unit NewUxTheme; | ||
|
||
|
@@ -1012,6 +1014,14 @@ _INTLIST = record | |
|
||
var | ||
EnableTheming: function(fEnable: BOOL): HRESULT; stdcall; | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
type | ||
TPreferredAppMode = (pamDefault, pamAllowDark, pamForceDark, pamForceLight, pamMax); | ||
|
||
var | ||
SetPreferredAppMode: function(appMode: TPreferredAppMode): TPreferredAppMode; stdcall; | ||
|
||
implementation | ||
|
||
|
@@ -1085,6 +1095,7 @@ procedure FreeThemeLibrary; | |
GetThemeDocumentationProperty := nil; | ||
DrawThemeParentBackground := nil; | ||
EnableTheming := nil; | ||
SetPreferredAppMode := nil; | ||
end; | ||
end; | ||
|
||
|
@@ -1100,6 +1111,15 @@ function InitThemeLibrary: Boolean; | |
Result := StrPas(Buf); | ||
end; | ||
|
||
function WindowsVersionAtLeast(const AMajor, AMinor: Byte; const ABuild: Word): Boolean; | ||
begin | ||
var OSVersionInfo: TOSVersionInfoEx; | ||
OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo); | ||
GetVersionEx(OSVersionInfo); | ||
var WindowsVersion := (Byte(OSVersionInfo.dwMajorVersion) shl 24) or (Byte(OSVersionInfo.dwMinorVersion) shl 16) or Word(OSVersionInfo.dwBuildNumber); | ||
Result := WindowsVersion >= Cardinal((AMajor shl 24) or (AMinor shl 16) or ABuild); | ||
end; | ||
|
||
begin | ||
Inc(ReferenceCount); | ||
|
||
|
@@ -1153,6 +1173,10 @@ function InitThemeLibrary: Boolean; | |
GetThemeDocumentationProperty := GetProcAddress(ThemeLibrary, 'GetThemeDocumentationProperty'); | ||
DrawThemeParentBackground := GetProcAddress(ThemeLibrary, 'DrawThemeParentBackground'); | ||
EnableTheming := GetProcAddress(ThemeLibrary, 'EnableTheming'); | ||
if WindowsVersionAtLeast(10, 0, 18362) then { 10.0.18362 = Windows 10 Version 1903 (May 2019 Update) } | ||
SetPreferredAppMode := GetProcAddress(ThemeLibrary, MakeIntResource(135)) | ||
else | ||
SetPreferredAppMode := nil; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jordanrussell
Member
|
||
end; | ||
end; | ||
Result := ThemeLibrary <> 0; | ||
|
Eh... I don't know about this. According to:
https://stackoverflow.com/questions/53501268/win10-dark-theme-how-to-use-in-winapi
ordinal 135 was changed from one function to another at one point. How do we know it won't change again in the future? That could lead to the IDE crashing when calling the function -- which sounds far worse than the menus not being rendered in dark mode.
On an unrelated note, the unit needs
{$MINENUMSIZE 4}
to make Delphi enumerated types match the size of C enum types (which is 4 bytes, not 1).