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);
hwnd
The control to apply dark mode to.
ApplyToControl reads the control's window class and selects an appropriate theme class:
| Window class | Theme applied |
|---|---|
| ComboBox | DarkMode_CFD |
| Edit | DarkMode_CFD |
| SysListView32 | DarkMode_ItemsView |
| Button (group box) | Theme stripped (so WM_CTLCOLORSTATIC can recolor the label) |
| Anything else | DarkMode_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