Our second goal towards accessibility is to improve the readability of visual and textual information of application.Assume that target end users for this post have some vision impairment. Visual impaired users respond differently to different contrast settings. Some of them prefer sharp, well-defined contrasts while others choose more muted contrast colors. Therefore, foreground and background color settings should offer proper contrast setting so that it is easier for user to read and understand application messages.
Windows operating systems provide this functionality through High contrast mode.From Control panel, it is set through Accessibility Options in XP, Ease of Access Center in Windows 7 and other equivalent facilities in other version of windows.
It is toggle on/off through this hot-Key
Press left ALT + left SHIFT + Print Screen
Supporting High Contrast mode
While designing you application, consider following points:
- Use system color scheme. Do not hard code hexadecimal values for foreground and background properties. In case of custom color scheme, allow the user to override it with user-selected contrast and color scheme.
- Do not rely on color alone, because user who cannot distinguish the color will not have access to that information.Convey information through other means often it is done through visual cue or sound.
In the below image, users who can distinguish red color will not be able to identify required field. - Alternative color should be used for high-contrast setting, as shown in the image.
- Remove background images or patterns, such as watermarks, so that text is visible.
In below figure, user cannot read the label text because of background image,in high contrast mode.
Walk through
For making your application to work effectively in HighContrast Mode, follow these steps .Consider sample application used in Keybaord Navigation.
- Create ColorScheme Method: First create a method to set color scheme of controls according to systems color. Determine whether the High Contrast mode is on/off by using SystemInformation.HighContrast property and assign the color accordingly. Systems colors can be selected through SystemColors class.
private void SetColorScheme() { this.lblMode.Text = SystemInformation.HighContrast?"HighContrast Mode":"Normal Mode"; if (SystemInformation.HighContrast) { this.lblFirstName.Image = null; this.txtBxAddress.BackColor = SystemColors.Window; this.txtBxAddress.ForeColor = SystemColors.WindowText; this.pictureBox1.Image = global::Sample3.Properties.Resources.HighCntrastDocument; } else { this.lblFirstName.Image = global::Sample3.Properties.Resources.BANR075; this.pictureBox1.Image = global::Sample3.Properties.Resources.Document2; this.txtBxAddress.BackColor = System.Drawing.Color.Red; this.txtBxAddress.ForeColor = System.Drawing.Color.Green; } }Set the color Scheme when the application starts i.e. in the constructor and when SystemInformation.HighContrast is changed dynamically.
- Hook up UserPreferenceChanged Event Procedure: Use SystemEvents.UserPreferenceChanged event to respond the change SystemInformation.HighContrast.Register the event in the constructor.
public DemoForm() { InitializeComponent(); SetColorScheme(); Microsoft.Win32.SystemEvents.UserPreferenceChanged += new Microsoft.Win32.UserPreferenceChangedEventHandler(OnSystemEvents_UserPreferenceChanged); } - Respond to UserPreferenceChanged Event: Set the color scheme whenever SystemInformation.HighContrast value is changed.
void OnSystemEvents_UserPreferenceChanged(object sender, Microsoft.Win32.UserPreferenceChangedEventArgs e) { SetColorScheme(); } - UnHook UserPreferenceChanged Event: Remember SystemEvents are static and they can be called on even after dispose or can hold strong reference of object until application exit. It is better to unsubscribe the event in dispose in order to avoid potential memory leaks.
protected override void Dispose(bool disposing) { Microsoft.Win32.SystemEvents.UserPreferenceChanged -= new Microsoft.Win32.UserPreferenceChangedEventHandler(OnSystemEvents_UserPreferenceChanged); if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
Testing High Contrast Mode
Turn on High contrast mode before running the application and check following points:
- All UI elements and controls should be visible.
- Active and inactive selection appearance should be differentiable
- In high contrast mode visual focus should be available.
- If your application supports multiple schemes function, verify all.
- No text truncation occurs.
- There should be no hard-coded colors.
Download source code.






