2

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.

  • Be aware that high-contrast mode and high-contrast theme are different ideas. If you're in high-contrast mode, you're probably using some high-contrast theme. But it's also possible to select a high-contrast theme without actually being in high-contrast mode. https://blogs.msdn.microsoft.com/oldnewthing/20081203-00/?p=19983 – Adrian McCarthy Jun 21 '16 at 22:08
  • @AdrianMcCarthy - That's a good point, would you object to me adding a note to that effect on my answer? – theB Jun 21 '16 at 22:31
  • I actually need to discover if we have the high contrast theme, not mode. I'll edit my question. edit: the reason for this is there is no way to get the width of the shadow area in the default windows 10 theme, and the high contrast theme in windows 10 is the only theme without the shadows. – Adrian Saldanha Jun 22 '16 at 21:10
  • I'm trying to do this http://stackoverflow.com/questions/32159675/retrieve-window-size-without-windows-shadows, except DwmGetAttribute always gives me the same size as GetWindowRect, so I was going to hack in the Windows 10 case and I noticed high contrast mode by default is the only mode without the shadows. – Adrian Saldanha Jun 22 '16 at 21:18
  • That is a completely different question. You cannot invalidate the answers you got. Close this question by marking it as answered and click the Ask Question button again. – Hans Passant Jun 22 '16 at 21:18
  • It's not answered unfortunately, I need to determine if we're in High Contrast theme, not mode. I'll ask another question if we can't determine this. – Adrian Saldanha Jun 22 '16 at 21:20
  • 1
    What @HansPassant is saying is that your original question *was* answered, and now you're trying to change the question. That's not fair to the people who have already answered, nor to the people who will come across this question in the future and be very confused. Close this question and ask another. – Mark Ransom Jun 22 '16 at 21:30
  • Well I mistyped the question (mode instead of theme) perhaps, but the question as it stands was what my original question was. I'll will open a new question, but I don't believe my original one has been answered either, which is what I've edited it too now. So both can stand I believe? I'm not new, just a new account. – Adrian Saldanha Jun 22 '16 at 22:13

2 Answers2

4

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.

theB
  • 6,450
  • 1
  • 28
  • 38
1

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;
Jayden
  • 3,276
  • 1
  • 10
  • 14