How can I put a bitmap or icon on a button face
You can use the Button.Image property to add an image to a button face. Use the Button.ImageAlign (and possibly Button.TextAlign) to layout your button face. You can also implement custom drawing on a button face as described in the FAQ entitled ‘How can I decorate a button face with custom drawing’.
How can I easily manage whether controls on my form are readonly or not
One way is to place all the controls into a single GroupBox and then use the GroupBox.Enabled property to manage whether the controls are editable or not.
How can I tell if the user has changed some system preference such as the locale or display settings
Use the static events in the SystemEvents class found in the Microsoft.Win32 namespace. There are many events in this class. Here are a couple: SystemEvents.DisplaySettingsChanged += new System.EventHandler(displaySettingsChanged); SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(userPreferencesChanged); …………. …………. private void displaySettingsChanged(object sender, EventArgs e) { MessageBox.Show(e.ToString()); } private void userPreferencesChanged(object sender, UserPreferenceChangedEventArgs e) { switch(e.Category) { case UserPreferenceCategory.Locale: MessageBox.Show(‘Changed locale’); break; default: MessageBox.Show(e.Category.ToString()); break; } }
What class or method do I use to retrieve system metrics like the width of a scrollbar
In the .NET framework, you use the SystemInformation class from the System.Windows.Forms namespace. This class has comparable information to what GetSystemMetrics() returned in VC6. There is also a Screen class that contains additions display device properties.
How can I tell if an ALT, Shift or CTL key is pressed without catching an event
Use the static property Control.ModifierKeys. Console.WriteLine(Control.ModifierKeys); if( (Control.ModifierKeys & Keys.Shift) != 0) Console.WriteLine(‘the shift key is down’); if( (Control.ModifierKeys & Keys.Alt) != 0) Console.WriteLine(‘the alt key is down’); if( (Control.ModifierKeys & Keys.Control) != 0) Console.WriteLine(‘the control key is down’);