SftButton/DLL 3.0 - Button Control
SftTree/DLL 8.0 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTree/OCX 8.0 (BETA) - Tree Control
SftButton/DLL 3.0 - Button Control
SftTree/DLL 8.0 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTree/OCX 8.0 (BETA) - Tree Control
SftTree/NET 2.0 - Tree Control
Handle dark-mode-related dialog messages. Paints WM_CTLCOLOR* responses with the dark palette, repaints radio-button labels in dark text, and re-applies dark mode to the dialog and children when the user flips the Windows setting at runtime.
C
BOOL SftDarkMode_HandleDialogMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam, INT_PTR* pResult);
hwndDlg
The dialog receiving the message.
msg, wParam, lParam
The message and its parameters as received by the dialog procedure.
pResult
Pointer to an INT_PTR that receives the dialog-proc return value when the function returns TRUE. Must not be NULL.
TRUE if the message was handled by the helper. The caller must return *pResult from its dialog procedure.
FALSE if the message was not handled. The caller continues with its own message routing.
HandleDialogMessage handles five categories of message:
| Message | Behavior |
|---|---|
| WM_CTLCOLORDLG | Returns the dark background brush so the dialog client area paints dark. |
| WM_CTLCOLORSTATIC, WM_CTLCOLOREDIT, WM_CTLCOLORBTN, WM_CTLCOLORLISTBOX | Sets dark text and background colors on the HDC and returns the dark brush so static labels, edits, buttons (group boxes) and listboxes paint with the dark palette. |
| WM_NOTIFY (NM_CUSTOMDRAW on a radio button) | Repaints the radio button label in dark text. Standard radio buttons ignore SetTextColor when themed; the helper steals the CDDS_PREPAINT stage and draws the label itself with DrawText in SFTDARKMODE_TEXT_COLOR (or COLOR_GRAYTEXT for disabled), then returns CDRF_SKIPDEFAULT. The radio glyph itself is still drawn by the system. |
| WM_SETTINGCHANGE / ImmersiveColorSet | Re-detects the current "Choose your mode" preference. If it changed, calls SftDarkMode_ApplyToWindow on the dialog and RefreshImmersiveColorPolicyState. Always re-applies themes to children via SftDarkMode_ApplyToChildren, invalidates the dialog, and forwards WM_SETTINGCHANGE to each direct child so they can re-render too. Accepts both LPCWSTR (Unicode procs) and LPCSTR (ANSI procs) forms of lParam. |
All handlers are gated on the helper being in dark mode. In light mode HandleDialogMessage returns FALSE for every message and the dialog's default message routing applies.
For a window procedure (returns LRESULT), use SftDarkMode_HandleWindowMessage instead.
INT_PTR CALLBACK MyDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
INT_PTR dmResult;
/* Application-specific handling first ... */
if (SftDarkMode_HandleDialogMessage(hwndDlg, msg, wParam, lParam, &dmResult))
return dmResult;
return FALSE;
}When sharing a dialog proc with other Softel vdm helpers (SftTabs page-host helpers, for example), HandleDialogMessage typically goes last - after SftTabs_HandleDialogMessage and SftTabs_TransparentControls but before the application's default-return path.
For MFC applications using the SftTabs dialog / page classes, HandleDialogMessage is called automatically - CSftTabsDialog and CSftTabsPage (in SftTbM.h) route through it from their OnWndMsg when SftDarkMode.h is included before SftTb.h. Application code only has to:
For MFC dialogs that do not derive from a SftTabs class, route HandleDialogMessage from the dialog's WindowProc or OnWndMsg override the same way the plain Win32 example does.
See Also Init | ApplyToDialog | IsActive | HandleWindowMessage | HandleMenuMessage
