HeaderPane
Main

Dark Mode Support

Share Link
Print

SftDarkMode_ApplyToControl

Apply dark mode theming to a single control. Picks the correct theme class for the control's window class and arms the per-window opt-in needed for dark NC scrollbars on edit / list controls.

C

void SftDarkMode_ApplyToControl(HWND hwnd);

Parameters

hwnd

The control to apply dark mode to.

Comments

ApplyToControl reads the control's window class and selects an appropriate theme class:

Window classTheme applied
ComboBoxDarkMode_CFD
EditDarkMode_CFD
SysListView32DarkMode_ItemsView
Button (group box)Theme stripped (so WM_CTLCOLORSTATIC can recolor the label)
Anything elseDarkMode_Explorer

For each, the helper calls AllowDarkModeForWindow, SetWindowTheme, and sends WM_THEMECHANGED so comctl32 reopens its theme handle.

Group boxes are a special case: they ignore SetTextColor when themed. ApplyToControl strips the theme on group boxes (so the label can be repainted dark by WM_CTLCOLORSTATIC). The WM_CTLCOLORSTATIC hook in SftDarkMode_HandleDialogMessage provides the dark text color and brush.

Edit and list NC scrollbars require both AllowDarkModeForWindow and an IAT hook in comctl32 - the hook is installed by SftDarkMode_Init, and ApplyToControl arms its per-window opt-in via SetWindowTheme. Bare SetWindowTheme alone does not produce dark scrollbars on standard controls.

ApplyToControl is normally called automatically by SftDarkMode_ApplyToChildren or SftDarkMode_ApplyToDialog. Call it directly only for controls created or shown after the parent dialog has already been themed.

See Also ApplyToChildren | ApplyToDialog | ApplyToComboBox


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