How to change system font windows 7 code#
using Microsoft.Win32 Īdd the following code to the constructor of your form to hook up required event handlers, and to change the default font in use for the form. For more information, see How to: Create a Windows Forms Application from the Command Line and Controls to Use on Windows Forms.Īdd a reference to the Microsoft.Win32 namespace to your code.
To use the desktop font and respond to font scheme changesĬreate your form, and add the controls you want to it. As shown in the following procedure, your code must change the default font to IconTitleFont to respond to changes in font size. The font returned by this call only changes when the screen resolution changes. Typically, the default font used by Windows Forms is the font returned by the Microsoft.Win32 namespace call to GetStockObject(DEFAULT_GUI_FONT). If you want your form to accommodate changes in font sizes dynamically, you can add code to your form.
You can adjust your Windows Forms application to react to these changes by increasing or decreasing the size of the form and all contained text whenever the font scheme changes. Changing these font settings is critical for users who are visually impaired and require larger type to read the text on their screens. In the Windows operating systems, a user can change the system-wide font settings to make the default font appear larger or smaller. How to: Respond to Font Scheme Changes in a Windows Forms Application