HeaderPane
Main
Hide

SftButton/DLL 3.0 - Button Control

Share Link
Print

SetDarkMode

Selects how the button control participates in Windows dark mode.

C

void SftButton_SetDarkMode(HWND hwndCtl, int mode);

C++

void CSftButton::SetDarkMode(int mode);

Parameters

hwndCtl

The window handle of the button control.

mode

The dark mode setting. One of the following values:

SFTBUTTON_DARKMODE_OFFAlways use the light palette, regardless of the Windows setting. This is the default.
SFTBUTTON_DARKMODE_ONAlways use the dark palette, regardless of the Windows setting.
SFTBUTTON_DARKMODE_AUTOFollow the Windows "Choose your mode" setting. The control automatically re-renders when the Windows setting flips.

Comments

SetDarkMode selects whether the button uses the dark or light color palette. The default is SFTBUTTON_DARKMODE_OFF, which keeps the button in the light palette regardless of the Windows setting - this preserves visual back-compatibility for applications written before dark mode existed. Applications that want to participate in dark mode should set SFTBUTTON_DARKMODE_AUTO to follow the Windows "Choose your mode" setting, or maintain their own Light / Dark toggle and switch each button to SFTBUTTON_DARKMODE_ON / OFF as the toggle changes.

When the mode is SFTBUTTON_DARKMODE_AUTO, the control sends SFTBUTTONN_DARKMODE_CHANGED to its parent window each time the active dark mode state flips so the application can repaint its own surrounding chrome.

Caller-supplied color overrides remain in effect in every mode - SetDarkMode does not override per-state background, gradient, text or border colors set by the application.

Dark mode requires Windows 10 or later. On earlier platforms the setting is stored but has no visual effect.

Examples

C

            }
            return TRUE;
        case IDC_DARK_MODE:
            if (HIWORD(wParam) == BN_CLICKED) {
                BOOL fDark = IsDlgButtonChecked(hwndDlg, IDC_DARK_MODE) == BST_CHECKED;
                int btnMode = fDark ? SFTBUTTON_DARKMODE_ON : SFTBUTTON_DARKMODE_OFF;
                int ids[] = { IDC_SFTBUTTON1, IDC_SFTBUTTON2, IDC_SFTBUTTON3 };
                for (int i = 0; i < (int)(sizeof(ids) / sizeof(ids[0])); ++i)
                    SftButton_SetDarkMode(GetDlgItem(hwndDlg, ids[i]), btnMode);
                SftDarkMode_SetActive(fDark);
                SftDarkMode_ApplyToDialog(hwndDlg);
                InvalidateRect(hwndDlg, NULL, TRUE);
            }
            return TRUE;
        }
        break;

See Also GetDarkMode | IsDarkModeActive | SetHighContrastMode | Dark Mode | High Contrast | Notifications


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