Recent

Author Topic: Windows 10 1809 Dark Theme  (Read 2274 times)

Pascal

  • Hero Member
  • *****
  • Posts: 832
Windows 10 1809 Dark Theme
« on: October 08, 2018, 10:25:52 am »
Is there a way to make Dark Theme work for apps build with Lazarus?

As i understood Microsoft added support for standard UI controls and they only react on Dark Theme if they are used in File Explorer.
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7446
Re: Windows 10 1809 Dark Theme
« Reply #1 on: October 08, 2018, 10:33:15 am »
Usually you need to toggle something in the manifest file to allow newer features to be used. Best to do some research on Microsoft sites.

rvk

  • Hero Member
  • *****
  • Posts: 3836
Re: Windows 10 1809 Dark Theme
« Reply #2 on: October 08, 2018, 10:58:10 am »
I don't think it is possible for desktop apps (other then setting High Contrast options for the desktop).

Quote
The real problem with the new Dark Mode setting is that it doesn’t affect the Windows desktop theme at all. Desktop applications like File Explorer continue using the normal, light theme.

Windows has a built-in dark theme for desktop applications, but it probably isn’t ideal. To enable it, head to Settings > Ease of Access > High Contrast. On the right, enable the “Turn on High Contrast” option and set the “Choose a Theme” dropdown to the “High Contrast Black” setting. Click “Apply” to save the setting.
https://www.howtogeek.com/222614/how-to-enable-windows-10s-hidden-dark-theme/

PascalDragon

  • Hero Member
  • *****
  • Posts: 626
  • Compiler Developer
Re: Windows 10 1809 Dark Theme
« Reply #3 on: October 08, 2018, 04:12:00 pm »
I don't think it is possible for desktop apps (other then setting High Contrast options for the desktop).

Quote
The real problem with the new Dark Mode setting is that it doesn’t affect the Windows desktop theme at all. Desktop applications like File Explorer continue using the normal, light theme.

Windows has a built-in dark theme for desktop applications, but it probably isn’t ideal. To enable it, head to Settings > Ease of Access > High Contrast. On the right, enable the “Turn on High Contrast” option and set the “Choose a Theme” dropdown to the “High Contrast Black” setting. Click “Apply” to save the setting.
https://www.howtogeek.com/222614/how-to-enable-windows-10s-hidden-dark-theme/

With the newest update it might be possible as Microsoft added Dark Theme support to File Explorer.

dbannon

  • Hero Member
  • *****
  • Posts: 692
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Windows 10 1809 Dark Theme
« Reply #4 on: June 16, 2019, 01:49:33 pm »
OK, posting to an old topic because its an old issue  :-)

My end users are getting excited about new Windows10 dark themes. Apparently 'some' applications now automatically switch themselves to a dark theme if the OS is so set.

I am wondering if anyone has yet found a way to determine if the (Windows) OS does in fact have that dark theme set ?

Its still most certainly not a case of the app inheriting its colours from the OS like we have on Linux and Mac but I guess I could, if I knew it was necessary, have each form reset its colours if the user appeared to have set a dark OS theme.

Otherwise, why bother to have an OS setting of Dark Theme ?

(And I still think Dark Themes are very, very ugly)

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

PascalDragon

  • Hero Member
  • *****
  • Posts: 626
  • Compiler Developer
Re: Windows 10 1809 Dark Theme
« Reply #5 on: June 17, 2019, 09:20:50 am »
There appears to be a registry key for this. See also this Stack Overflow question.

dbannon

  • Hero Member
  • *****
  • Posts: 692
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Windows 10 1809 Dark Theme
« Reply #6 on: June 18, 2019, 09:21:10 am »
Thanks PascalDragon, looks like you are right !

Code: Pascal  [Select]
  1.  procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   RegValue : string='';
  4.   Registry : TRegistry;
  5. begin
  6.   Registry := TRegistry.Create;
  7.   try
  8.     Registry.RootKey := HKEY_CURRENT_USER;
  9.     if Registry.OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') then // this exists in HKCU
  10.         RegValue := inttostr(Registry.ReadInteger('AppsUseLightTheme'))
  11.     else showmessage('Key not found');
  12.     if RegValue <> '' then
  13.         showmessage('Key Value = ' + RegValue);
  14.   finally
  15.     Registry.Free;
  16.   end;
  17. end;
           

Your link mentions it in HKLM but I could only find it in _CURRENT_USER , its a REG_DWORD, 1 if normal 'light' theme, '0' if set to DarkTheme.

My guess is if its not been set by the user, .OpenKeyReadOnly() will return false, assume default light theme.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng