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
SftDarkMode is a single-header helper that adds dark mode support to Windows dialogs and applications. The header is shared across the Softel vdm controls (SftTree, SftTabs, SftBox, SftMask, SftButton) in both their DLL and ActiveX (OCX) editions - the same companion API and color palette is used throughout.
The header provides:
SftDarkMode.h is a stb-style single-header library: declarations are always available; the implementation is compiled only when SFTDARKMODE_IMPLEMENTATION is defined before the include. Define it in exactly one .c / .cpp file per executable; include the header without the define everywhere else that needs the declarations.
// In one .c / .cpp file (e.g. DarkMode.cpp):
#define SFTDARKMODE_IMPLEMENTATION
#include "SftDarkMode.h"
// Everywhere else:
#include "SftDarkMode.h"A typical adoption is four call sites:
Each Softel vdm control honors the dark state automatically when its own SetDarkMode is set to AUTO (or stays in OFF when the application has not opted in).
| Function | Description |
|---|---|
| SftDarkMode_Init | Initialize the dark-mode helper. Call once at application startup, before creating any windows. |
| SftDarkMode_IsActive | Returns TRUE if dark mode is currently active. |
| SftDarkMode_SetActive | Override the dark / light state programmatically. |
| SftDarkMode_ApplyToWindow | Apply dark mode to a top-level window's non-client area (title bar, frame). |
| SftDarkMode_ApplyToControl | Apply dark mode theming to a single control. Picks the correct theme class for the control's window class. |
| SftDarkMode_ApplyToChildren | Apply dark mode theming to every direct child of a window. |
| SftDarkMode_ApplyToComboBox | Apply dark mode to a combo box (parent and its internal children). |
| SftDarkMode_ApplyToDialog | Apply dark mode to a dialog and all its children. The recommended one-shot call from WM_INITDIALOG. |
| SftDarkMode_GetNaturalChildSize | Compute the natural content size of a form-style window by unioning the bounding rects of its direct children. Useful for CScrollView::SetScrollSizes after a PerMonitorV2 DPI change. |
| SftDarkMode_HandleDialogMessage | Handle dark-mode dialog messages (WM_CTLCOLOR*, WM_NOTIFY radio buttons, WM_SETTINGCHANGE). Writes the result through INT_PTR*. For window procedures, use SftDarkMode_HandleWindowMessage (writes through LRESULT*). |
| SftDarkMode_HandleMenuMessage | Experimental. Draw the menu bar and items in dark colors using undocumented Windows messages. |
| Constant | Value | Purpose |
|---|---|---|
| SFTDARKMODE_BG_COLOR | RGB(32, 32, 32) | Dark background fill - used for the dialog client area and the dark brush returned from WM_CTLCOLOR*. |
| SFTDARKMODE_TEXT_COLOR | RGB(230, 230, 230) | Dark-mode text color. |
| SFTDARKMODE_BTNFACE_COLOR | RGB(45, 45, 45) | Dark button-face / panel color (slightly lighter than the dialog background). |
| SFTDARKMODE_HOT_COLOR | RGB(55, 55, 55) | Dark "hot" / hover background. |
| SFTDARKMODE_PRESSED_COLOR | RGB(32, 32, 32) | Dark pressed-state background (matches BG so a pressed button visually merges with the dialog). |
| SFTDARKMODE_IMPLEMENTATION | (preprocessor) | Define before #include "SftDarkMode.h" in exactly one source file to compile the implementation. |
Dark mode is a Windows 10 (1809+) and Windows 11 feature. SftDarkMode degrades gracefully on earlier platforms - the helper functions are still callable and return safely, but no dark-mode chrome is applied. Several APIs the helper uses (SetPreferredAppMode, AllowDarkModeForWindow, RefreshImmersiveColorPolicyState, FlushMenuThemes) are undocumented uxtheme.dll exports loaded by ordinal at runtime.
The header itself is character-set neutral - it uses WCHAR string comparisons internally for the ImmersiveColorSet setting name and accepts both LPCWSTR and LPCSTR forms of the WM_SETTINGCHANGE lParam so it runs correctly under both Unicode and MultiByte (ANSI) procedures.
The header issues #pragma comment(lib, ...) directives for dwmapi.lib and uxtheme.lib when compiled under Microsoft Visual C++. No additional linker setup is required.
