Skip to content

Feature ideas : add support for High Contrast mode. #40

Open

Description

@OrthodoxWindows

The high contrast mode is a mode introduced in Windows 8, to compensate for the discontinuation of support for the classic theme for visually impaired users. For Win32 programs, it uses the Aero Lite visual style in a particular mode (much like Aero's "Dark" mode), which forces rendering by Win32 color settings. In UWP/WinUI apps, it forces the use of Win32 color settings, which is the only way, since UWP apps don't work with the classic theme. The parameters used are only certain colors, less than with the classic theme. Tomorrow I will post the links to the Microsoft documentation on this subject, as well as the research I have done on the parameters used, and the results on the Win32 and UWP type elements and for the Windows 10 taskbar and start menu (I don't is not sought for Windows 8 and 11).

It seems to me that the result Win32 programs are almost between Windows 8/10/11, but much less the UWP type elements.

Activity

  1. changed the title [-]Feature ideas : support High-Contrast mode.[/-] [+]Feature ideas : add support for High Contrast mode.[/+] on Sep 7, 2022
  2. Abdelrhman-AK commented on Sep 7, 2022

    @Abdelrhman-AK
    Owner

    That is great! I'll work on it when you post the documentation.

  3. self-assigned this
    on Mar 2, 2024
  4. OrthodoxWindows commented on Mar 27, 2024

    @OrthodoxWindows
    Author

    I will try to quickly provide you with the necessary documentation (probably in the coming days).

  5. Abdelrhman-AK commented on Apr 8, 2024

    @Abdelrhman-AK
    Owner

    I am finalizing version 1.0.9.1 because I won't have any time in a few days. I might include this feature if it functions correctly.

    This user32 function manages to enable/disable high contrast colors:

            /// <summary>
            /// Enable or disable the high contrast mode.
            /// </summary>
            /// <param name="enable"></param>
            /// <returns></returns>
            public static bool SetHighContrast(bool enable)
            {
                HIGHCONTRAST highContrast = new()
                {
                    cbSize = Marshal.SizeOf(typeof(User32.HIGHCONTRAST)),
                    dwFlags = enable ? 0x1u : 0x0u // Set to HCF_HIGHCONTRASTON to enable, 0 to disable
                };
    
                return User32.SystemParametersInfo(0x0043 /*User32.SPI.SPI_SETHIGHCONTRAST*/, highContrast.cbSize, ref highContrast, 0x01 | 0x02);
            }
    
            [StructLayout(LayoutKind.Sequential)]
            public struct HIGHCONTRAST
            {
                public int cbSize;
                [MarshalAs(UnmanagedType.U4)]
                public uint dwFlags;
                public string lpszDefaultScheme;
            }

    Unfortunately, customizing colors is not working as it should. To make colors synchronized with the system, I should apply classic colors two or more times, and sometimes not applied at all, and this won't be suitable for users.

  6. Abdelrhman-AK commented on Apr 23, 2024

    @Abdelrhman-AK
    Owner

    This feature is coming soon in a new update.

  7. OrthodoxWindows commented on Apr 25, 2024

    @OrthodoxWindows
    Author

    Thank you for these changes, and sorry for having forgotten this discussion a little...
    To clarify, high contrast mode (or rather the associated API) has the particularity of applying certain classic Win32 colors to modern elements (taskbar, start screen, UWP applications).
    What I promised to provide you with is a detailed plan of the colors corresponding to the different elements. I will provide this to you in the future, in a separate discussion.

  8. OrthodoxWindows commented on Apr 25, 2024

    @OrthodoxWindows
    Author

    Regarding the synchronization problem, it may be because of the registry keys in which WinPaletter writes.
    You may remember the problem with the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\DefaultColors\Standard key; there is a neighboring key (HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\DefaultColors\HighContrast), which takes care of the colors used in high contrast mode. Obviously, the colors are written in duplicate in this key and the standard key for colors (HKCU\Control Panel\Colors), only if a high contrast theme is applied I'm not sure if this is the only problem, but it might be part of the answer.

  9. OrthodoxWindows commented on Apr 25, 2024

    @OrthodoxWindows
    Author

    After testing, I noticed that the colors applied (regardless of the selected scheme) are those of the previous high contrast theme applied with the default theme engine. For example, I had just applied the High Contrast White theme with the system, then switched to Windows Aero (so I was no longer in high contrast mode). Then, I activated the high contrast with WinPaletter, keeping the same color scheme (Aero fallback); the majority of the colors went to High Contrast White. The only colors that apply seem to be those that are not managed by the visual style and therefore appear all the time (like the window background), and the colors on "modern" elements (UWP type).

  10. OrthodoxWindows commented on Apr 25, 2024

    @OrthodoxWindows
    Author

    If you want a screen recording of that, I can provide it.

  11. Abdelrhman-AK commented on Apr 26, 2024

    @Abdelrhman-AK
    Owner

    If you want a screen recording of that, I can provide it.

    If this is possible, then please post it so that I can understand it more, or write steps to be made into the Windows Registry.

  12. OrthodoxWindows commented on May 2, 2024

    @OrthodoxWindows
    Author

    Here is the screen recording :

    UkqyPflWic.mp4

    And additional screenshots :
    ApplicationFrameHost_Xy43k6JqjH
    imdisplay_2IBqQLLdSz

    The theme applied is the default Windows theme (including AeroFallback). The last high contrast theme applied was HighContrastWhite. When enabling high contrast mode with WinPaletter, the following are correctly applied: Metro/UWP, Win32 with classic theme and DWM title bar. In contrast, Win32 elements dependent on the visual style are displayed with the colors of the previous high contrast theme (here High contrast white).

  13. Abdelrhman-AK commented on May 2, 2024

    @Abdelrhman-AK
    Owner

    Thank you for these information!

    • I was able to reproduce the issue. Reapplying classic colors multiple times with the applications closed—like the Registry Editor and others—fixed the problem for me.

    • Even if I erase the LastHighContrastTheme before setting high contrast, it reverts back to the same setting, and I don't know where the source of this setting is.

    • Even though I send a signal to Windows to update applications and Windows UI, it doesn't seem to affect the high-contrast colors.

         // Broadcast the system message to notify about the setting change
         User32.SendMessage(IntPtr.Zero, User32.WindowsMessages.WM_SETTINGCHANGE | User32.WindowsMessages.WM_THEMECHANGED | User32.WindowsMessages.WM_SYSCOLORCHANGE, IntPtr.Zero, IntPtr.Zero);

    Using real Windows 11:

    This is the first applying trial:
    0

    This is the third trial:
    1

    This is after trying a different scheme:
    2


    Using Windows 10 VM:

    This is the first applying trial:
    10_0

    This is the second applying trial:
    10_1

    This is after a logoff and logon. It wasn't colored correctly until I did that:
    10_2


    The conclusion is that I don't know the correct method to synchronize colors when high-contrast mode is enabled.

    Temporarily, reapplying Classic Colors multiple times, then logging off and back on, fixes the issue.

    If I (or you) find a solution , I'll implement it in 2 or 3 weeks from now, as I currently don't have enough time for coding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions