Windows

Dark window frame on Windows 10

From time to time I’m encountering a problem that app has dark color theme, but window frame is light. So here I’ll save two ways to change it on Windows 10.

For app users

I’ll tell you right away: this way won’t be useful if the accent color is important to you.

Open Registry Editor and find HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM section. You’ll need the following parameters from it:

  • ColorPrevalence: DWORD = 1
    This parameter allows to use accent color as title bar color.
  • AccentColor and AccentColorInactive: DWORD = color in ABGR format (hexadecimal).
    Colors for active and inactive mode.

Here’s an example of registry file where color #000000 is used for active window title and #212121 is used for inactive one:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM]
"ColorPrevalence"=dword:00000001
"AccentColor"=dword:ff000000
"AccentColorInactive"=dword:ff212121

For app coders

You’ll need DwmSetWindowAttribute function:

HRESULT DwmSetWindowAttribute(
       HWND    hwnd,        // window
       DWORD   dwAttribute, // attribute itself
  [in] LPCVOID pvAttribute, // value
       DWORD   cbAttribute  // value size in bytes
);

Attribute values are described by DWMWINDOWATTRIBUTE but we specifically interested in DWMWA_USE_IMMERSIVE_DARK_MODE. Documentation says it’s equal to 20, however until 20H1 version the value has been equal to 19 .

That’s how i’ve tried to implement autodetect of window frame theme in Ultimate++ :

  HRESULT (WINAPI *DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
  DllFn(DwmSetWindowAttribute, "dwmapi.dll", "DwmSetWindowAttribute");
  if (DwmSetWindowAttribute) {
    BOOL useDarkTheme = IsDarkTheme(); 
    DwmSetWindowAttribute(
      top->hwnd, 20, /* 20 is DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE */
      &useDarkTheme, sizeof(useDarkTheme));
  }