SftTree/DLL 7.5 - 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/DLL 7.5 - 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/NET 2.0 - Tree Control
Experimental. Render a window's menu bar and menu items in dark colors using undocumented Windows messages. Call from the window procedure of any window that has a menu bar.
C
BOOL SftDarkMode_HandleMenuMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
hwnd
The window receiving the message.
msg, wParam, lParam
The message and its parameters as received by the window procedure.
pResult
Pointer to an LRESULT that receives the window-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 window procedure.
FALSE if the message was not handled. The caller continues with its own message routing.
This function uses undocumented Windows messages and may break with future Windows updates. Use at your own risk - it is provided as an opt-in for applications that want a dark menu bar today and accept that the implementation is not part of the documented Win32 contract.
The function is a no-op when the helper is not in dark mode - the menu paints with the system default.
HandleMenuMessage handles three message families:
| Message | Behavior |
|---|---|
| WM_UAHDRAWMENU (0x0091) | Fills the menu bar background with the dark brush. |
| WM_UAHDRAWMENUITEM (0x0092) | Draws each menu item with the dark palette - dark background, light text, hover / selected states use a slightly lighter background, disabled items use COLOR_GRAYTEXT. Honors ODS_NOACCEL for hidden underlines. |
| WM_NCPAINT, WM_NCACTIVATE | Lets the default proc paint the NC area first, then overpaints the one-pixel border below the menu bar with the dark brush so it blends with the dark menu instead of showing a default-color seam. |
LRESULT CALLBACK MyWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT dmResult;
/* Optional: dark menu bar (experimental) */
if (SftDarkMode_HandleMenuMessage(hwnd, msg, wParam, lParam, &dmResult))
return dmResult;
/* Standard dark mode handling */
INT_PTR dmDlgResult;
if (SftDarkMode_HandleWindowMessage(hwnd, msg, wParam, lParam, &dmDlgResult))
return (LRESULT)dmDlgResult;
return DefWindowProc(hwnd, msg, wParam, lParam);
}Most applications do not need a dark menu bar - dialog-only applications have no menu, and many MFC applications use a docked toolbar / ribbon rather than a top-level menu. HandleMenuMessage is intended for the small number of legacy SDI / MDI applications where a dark menu bar matters.
The function relies on the undocumented WM_UAHDRAWMENU / WM_UAHDRAWMENUITEM messages that Windows sends to the window proc when AllowDarkModeForWindow has been called - which SftDarkMode_ApplyToWindow (and therefore SftDarkMode_ApplyToDialog) does. If those messages stop being sent in a future Windows build, HandleMenuMessage stops doing anything but remains safely callable.
See Also HandleDialogMessage | ApplyToWindow
