Adrian Saldanha
Adrian Saldanha

Reputation: 21

How to determine if High Contrast theme is on in Windows 10?

In Windows 10, high contrast theme is the only theme which behaves differently than the default Windows 10 theme with regards to the borders.

I want to detect if the user is in High Contrast theme in Windows 10 for this purpose.

Upvotes: 2

Views: 1696

Answers (2)

Jayden
Jayden

Reputation: 3286

We can use AccessibilitySettings class to get the info high contrast. And use AccessibilitySettings.HighContrast to indicate whether the system high contrast feature is on or off.

For example:

Windows::UI::ViewManagement::AccessibilitySettings^ accessibilitySettings = ref new Windows::UI::ViewManagement::AccessibilitySettings;
Boolean ishighcontrast = accessibilitySettings->HighContrast;

Upvotes: 1

theB
theB

Reputation: 6738

The way to determine if the system is currently in High contrast mode is to use SystemParametersInfo to get a HIGHCONTRAST structure which has all the information you need.

A simple example:

HIGHCONTRAST info = { 0 };
info.cbSize = sizeof(HIGHCONTRAST);
BOOL ok = SystemParametersInfoW(SPI_GETHIGHCONTRAST, 0, &info, 0);

if (ok)
{
    if (info.dwFlags & HCF_HIGHCONTRASTON)
    {
        wcout << L"High Contrast On" << endl;
    }
    else
    {
        wcout << L"High Contrast Off" << endl;
    }
}

See the documentation for HIGHCONTRAST for information about what other flags are available.

Upvotes: 4

Related Questions