HeaderPane
Main

Dark Mode Support

Share Link
Print

SftDarkMode_HandleWindowMessage

Handle dark-mode-related window messages. Identical behavior to SftDarkMode_HandleDialogMessage; the result is written through an LRESULT* (the return type of a window procedure) instead of INT_PTR* (the dialog procedure return type).

C

BOOL SftDarkMode_HandleWindowMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* pResult);

Parameters

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.

Return Value

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.

Comments

See SftDarkMode_HandleDialogMessage for the full list of messages handled and their behavior. HandleWindowMessage is the window-proc form of the same helper.

Usage in window procedures

LRESULT CALLBACK MyWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    LRESULT dmResult;
    if (SftDarkMode_HandleWindowMessage(hwnd, msg, wParam, lParam, &dmResult))
        return dmResult;

    /* Application-specific handling ... */

    return DefWindowProc(hwnd, msg, wParam, lParam);
}

MFC frame and view windows

For MFC classes that override WindowProc (CFrameWnd, CMDIFrameWnd, CView subclasses), call HandleWindowMessage from the override. If you also call SftDarkMode_HandleMenuMessage from the same WindowProc, both helpers can share an LRESULT local because both take LRESULT*.

LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    LRESULT dmResult;
    if (SftDarkMode_HandleMenuMessage(m_hWnd, message, wParam, lParam, &dmResult))
        return dmResult;
    if (SftDarkMode_HandleWindowMessage(m_hWnd, message, wParam, lParam, &dmResult))
        return dmResult;
    return CFrameWnd::WindowProc(message, wParam, lParam);
}

See Also Init | ApplyToWindow | IsActive | HandleDialogMessage | HandleMenuMessage


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