Fix safe work

This commit is contained in:
alinvip22@gmail.com
2023-05-06 11:54:48 +05:00
parent 0c887a8980
commit 329ea5a41b
2 changed files with 25 additions and 9 deletions
+15 -3
View File
@@ -50,17 +50,29 @@ end;
procedure TFormHelper.SetWindowColorMode(IsDark: Boolean);
begin
SetWindowColorModeFor(handle, IsDark);
try
SetWindowColorModeFor(handle, IsDark);
except
//
end;
end;
procedure TFormHelper.SetWindowColorModeAsSystem;
begin
SetWindowColorModeAsSystemFor(Handle);
try
SetWindowColorModeAsSystemFor(Handle);
except
//
end;
end;
class function TFormHelper.SystemIsDarkMode: Boolean;
begin
Result := IsDarkMode;
try
Result := IsDarkMode;
except
Result := False;
end;
end;
{$ELSE}
+10 -6
View File
@@ -123,13 +123,17 @@ var
LRegistry: TRegistry;
begin
Result := False;
LRegistry := TRegistry.Create;
try
LRegistry.RootKey := HKEY_CURRENT_USER;
if LRegistry.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize') then
Result := not LRegistry.ReadBool('AppsUseLightTheme');
finally
LRegistry.Free;
LRegistry := TRegistry.Create;
try
LRegistry.RootKey := HKEY_CURRENT_USER;
if LRegistry.OpenKeyReadOnly('\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize') then
Result := not LRegistry.ReadBool('AppsUseLightTheme');
finally
LRegistry.Free;
end;
except
Result := False;
end;
end;