Change the color of the title bar (caption) of a win32 application

You can change window title bar color / behaviour with DWMAPI’s DwmSetWindowAttribute function in Win32.

NOTE: Might require Windows SDK 10.0.22000.0 (aka first Windows 11 SDK) as DWMWA_USE_IMMERSIVE_DARK_MODE|DWMWA_BORDER_COLOR|DWMWA_CAPTION_COLOR were not documented in Windows SDK 10.0.19041.0 (latest Windows 10 SDK). People have got DWMWA_USE_IMMERSIVE_DARK_MODE working before the public documentation of the variable by simply using dwAttribute as 20 (or 19 if Windows was before Windows 10 20H1). Here is an example of Qt using it in their Windows platform integration by allowing application to use it by passing -platform windows:darkmode=1 flag when launching the application.

To enable immersive dark mode (available in Windows 10 / 11, but undocumented in Windows 10 SDK (can be used by setting value as dwAttribute as 20), value was 19 pre Windows 10 20H1 Update)

  • Immersive Dark Mode Enabled
  • Immersive Dark Mode Enabled Out of Focus
#include <dwmapi.h>

BOOL USE_DARK_MODE = true;
BOOL SET_IMMERSIVE_DARK_MODE_SUCCESS = SUCCEEDED(DwmSetWindowAttribute(
    WINhWnd, DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE,
    &USE_DARK_MODE, sizeof(USE_DARK_MODE)));

To change border color (only in Windows 11 SDK)

  • Border Color set to 0x00FFFFFF
  • Border Color set to 0x00505050
#include <dwmapi.h>

COLORREF DARK_COLOR = 0x00505050;
BOOL SET_CAPTION_COLOR = SUCCEEDED(DwmSetWindowAttribute(
    WINhWnd, DWMWINDOWATTRIBUTE::DWMWA_BORDER_COLOR,
    &DARK_COLOR, sizeof(DARK_COLOR)));

To change caption color (only in Windows 11 SDK)

  • Caption Color set to 0x00FFFFFF
  • Caption Color set to 0x00505050
#include <dwmapi.h>

COLORREF DARK_COLOR = 0x00505050;
BOOL SET_CAPTION_COLOR = SUCCEEDED(DwmSetWindowAttribute(
    WINhWnd, DWMWINDOWATTRIBUTE::DWMWA_CAPTION_COLOR,
    &DARK_COLOR, sizeof(DARK_COLOR)));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)