HeaderPane
Main

Dark Mode Support

Share Link
Print

SftDarkMode_ApplyToWindow

Apply dark mode to a top-level window's non-client area. Sets the dark title bar through DWM and forces the system to recompute the NC area so the title bar repaints in the new color.

C

void SftDarkMode_ApplyToWindow(HWND hwnd);

Parameters

hwnd

The top-level window to apply dark mode to.

Comments

ApplyToWindow handles the window aspect of dark mode - title bar color, frame, and the dark-mode opt-in. It does not touch the window's children. Use SftDarkMode_ApplyToDialog for the typical dialog scenario where the dialog and every child should be themed in one call.

The helper sets the DWMWA_USE_IMMERSIVE_DARK_MODE attribute through DwmSetWindowAttribute (using both attribute index 19 and 20 to cover Windows 10 1809-1903 builds), calls AllowDarkModeForWindow on the window, and forces an NC redraw via SetWindowPos(... | SWP_FRAMECHANGED).

On Windows builds that do not support the immersive dark mode attribute, DwmSetWindowAttribute returns an error which is ignored - ApplyToWindow has no visible effect on those platforms.

See Also ApplyToDialog | ApplyToControl | ApplyToChildren


Last Updated 05/09/2026 - (email)
© 2026 Softel vdm, Inc.