Defines whether a control is rendered using a dark color palette.
C
int WINAPI SftDate_GetDarkMode(HWND hwndCtl); BOOL WINAPI SftDate_SetDarkMode(HWND hwndCtl, int mode); BOOL WINAPI SftDate_IsDarkModeActive(HWND hwndCtl);
C++
int CSftDate::GetDarkMode() const; int CSftCalendar::GetDarkMode() const; BOOL CSftDate::SetDarkMode(int mode); BOOL CSftCalendar::SetDarkMode(int mode); BOOL CSftDate::IsDarkModeActive() const; BOOL CSftCalendar::IsDarkModeActive() const;
hwndCtl
The window handle of the date field control (SftDate) or the month calendar control (SftCalendar).
mode
Defines the dark mode setting. mode can be one of the following values:
| SFTDATE_DARKMODE_OFF | The control is always rendered using the light color palette. This is the default. |
| SFTDATE_DARKMODE_ON | The control is always rendered using the dark color palette, regardless of the Windows system setting. |
| SFTDATE_DARKMODE_AUTO | The control follows the current Windows "Choose your mode" setting (Light / Dark) and switches automatically when the user changes the system setting. |
GetDarkMode returns the dark mode setting, one of the values listed above.
SetDarkMode returns TRUE if mode is valid, otherwise FALSE.
IsDarkModeActive returns TRUE if dark mode is currently in effect, otherwise FALSE. When the dark mode setting is SFTDATE_DARKMODE_AUTO, the return value reflects the current Windows system setting. While high contrast mode is active (IsHighContrastActive), IsDarkModeActive returns FALSE, as the contrast theme's colors are used instead.
The GetDarkMode, SetDarkMode and IsDarkModeActive functions define and retrieve a control's dark mode setting. Dark mode applies to all parts of the control, including the dropdown of a date field control.
When mode is SFTDATE_DARKMODE_AUTO, the control re-renders automatically when the user toggles the Windows Light / Dark setting and sends the NM_SFTDATE_DARKMODE_CHANGED notification, so the application can repaint other UI to match. The control learns about the change of the system setting through the WM_SETTINGCHANGE message, which the parent window must forward to the control (see Dark Mode).
Colors defined by the application (SetColor, special dates, NM_SFTDATE_DAYFORMATTING) are used as given in dark mode too; only the default colors and system colors follow the mode.
High contrast mode takes precedence over dark mode (see SetHighContrastMode).
if (fShow)
for (d = 0; d < 5; ++d)
SftDate_AddSpecialDate(controls[i], &days[d]);
}
}
static void SetColorScheme(HWND hwndCtl, BOOL fOn)
{
BOOL fDark = SftDate_IsDarkModeActive(hwndCtl);
int k;
for (k = 0; k < (int) (sizeof(g_colors) / sizeof(g_colors[0])); ++k)
SftDate_SetColor(hwndCtl, g_colors[k].index, !fOn ? SFTDATE_NOCOLOR : fDark ? g_colors[k].dark : g_colors[k].light);
}
static void ApplyOption(HWND hwndDlg, int id)
{
{ SFTDATE_COLOR_SELECTEDFORE, RGB(255, 255, 255), RGB(255, 255, 255) },
{ SFTDATE_COLOR_RANGEBACK, RGB(250, 225, 190), RGB(95, 60, 20) },
{ SFTDATE_COLOR_SEGMENTBACK, RGB(225, 140, 30), RGB(225, 140, 30) },
{ SFTDATE_COLOR_SEGMENTFORE, RGB(255, 255, 255), RGB(255, 255, 255) },
};
static void SetColorScheme(CSftDateBase& control, BOOL fOn)
{
BOOL fDark = control.IsDarkModeActive();
for (int k = 0; k < _countof(g_colors); ++k)
control.SetColor(g_colors[k].index, !fOn ? SFTDATE_NOCOLOR : fDark ? g_colors[k].dark : g_colors[k].light);
}
static SYSTEMTIME MakeDate(int year, int month, int day)
{
SYSTEMTIME st;See Also C/C++ API | Categories | Notifications