C# Source Code: Detecting changes in display settings and other user settings
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
C# Source Code
Detecting changes in display settings and other user settings
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Friday, October 29, 2004
Hits:
1713
Category:
Windows Forms/GUI/Controls
Article:
To pick up system events use the static events in the SystemEvents class found in the Microsoft.Win32 namespace. There are a number of system events that can been listened for using this class. To detected any changes in the display settings or user preferences use the following code: // Hook the display settings changed event SystemEvents.DisplaySettingsChanged += new System.EventHandler(OnDisplaySettingsChanged); // Hook the user preference settings changed event SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(OnUserPreferencesChanged); ///
/// Called when a user changes a display setting ///
///
///
private void OnDisplaySettingsChanged(object sender, EventArgs e) { MessageBox.Show(e.ToString()); } ///
/// Called when a user changes a preference ///
///
///
private void OnUserPreferencesChanged(object sender, UserPreferenceChangedEventArgs e) { switch(e.Category) { case UserPreferenceCategory.Locale: MessageBox.Show("Locale Changed..."); break; default: MessageBox.Show(e.Category.ToString() + "..."); break; } }
Terms and Conditions
Support this site
Download a trial version of the best FTP application on the internet