HeaderPane
Main

Dark Mode Support

Share Link
Print

SftDarkMode_Init

Initialize the dark-mode helper. Detects the current "Choose your mode" preference, resolves the undocumented uxtheme.dll dark-mode entry points, hooks comctl32's delay-load import of OpenNcThemeData so dark NC scrollbars work on standard controls, and creates the shared dark background brush.

C

void SftDarkMode_Init(void);

Parameters

None.

Comments

Call exactly once at application startup, before any window is created. Typical call sites:

  • Plain Win32: from WinMain, before the first DialogBox / CreateWindow / DialogBoxIndirect call.
  • MFC: from CWinApp::InitInstance, before the first dialog is constructed.

Calling Init multiple times is harmless but wasteful - the second and later calls reload uxtheme.dll, re-resolve the same ordinal exports, and recreate the dark brush. Pair with no explicit shutdown - the helper does not allocate per-process resources that need releasing on exit.

Init is what makes the rest of the SftDarkMode API actually do anything. Without it, SftDarkMode_IsActive returns FALSE, the ApplyTo* functions silently no-op, and SftDarkMode_HandleDialogMessage returns FALSE for every message.

Note: the implementation must be compiled into the application by defining SFTDARKMODE_IMPLEMENTATION in exactly one source file before including SftDarkMode.h. Without that define the linker will fail with an unresolved symbol on SftDarkMode_Init.

See Also IsActive | SetActive | ApplyToDialog | HandleDialogMessage


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