File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
src/System.Windows.Forms/src/System/Windows/Forms Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ public sealed partial class Application
50
50
51
51
private const string DarkModeKeyPath = "HKEY_CURRENT_USER\\ SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Themes\\ Personalize" ;
52
52
private const string DarkModeKey = "AppsUseLightTheme" ;
53
- private const int SystemDarkModeDisabled = - 1 ;
53
+ private const int SystemDarkModeDisabled = 1 ;
54
54
55
55
/// <summary>
56
56
/// Events the user can hook into
@@ -284,7 +284,7 @@ public static void SetColorMode(SystemColorMode systemColorMode)
284
284
return ;
285
285
}
286
286
287
- if ( GetSystemColorModeInternal ( ) > SystemDarkModeDisabled )
287
+ if ( GetSystemColorModeInternal ( ) != SystemDarkModeDisabled )
288
288
{
289
289
s_systemColorMode = SystemColorMode . Dark ;
290
290
return ;
@@ -367,10 +367,11 @@ private static int GetSystemColorModeInternal()
367
367
368
368
try
369
369
{
370
- systemColorMode = ( Registry . GetValue (
370
+ // 0 for dark mode and |1| for light mode.
371
+ systemColorMode = Math . Abs ( ( Registry . GetValue (
371
372
keyName : DarkModeKeyPath ,
372
373
valueName : DarkModeKey ,
373
- defaultValue : SystemDarkModeDisabled ) as int ? ) ?? systemColorMode ;
374
+ defaultValue : SystemDarkModeDisabled ) as int ? ) ?? systemColorMode ) ;
374
375
}
375
376
catch ( Exception ex ) when ( ! ex . IsCriticalException ( ) )
376
377
{
You can’t perform that action at this time.
0 commit comments