Csharp/C Sharp by API/Microsoft.Win32/SystemEvents

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

SystemEvents.UserPreferenceChanged

 

using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
public class Form1 : Form
{
    private System.Windows.Forms.Label label2;
    
  public Form1() {
        this.Font = SystemFonts.IconTitleFont;
        this.AutoScaleDimensions = new System.Drawing.SizeF(6.0F, 13.0F);
        InitializeComponent();
        SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
  }
    private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
    {
        if (e.Category == UserPreferenceCategory.Window)
        {
            this.Font = SystemFonts.IconTitleFont;
        }
    }
    private void InitializeComponent()
    {
        this.label2 = new System.Windows.Forms.Label();
        this.SuspendLayout();
        // 
        // label2
        // 
        this.label2.Location = new System.Drawing.Point(12, 9);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(220, 55);
        this.label2.TabIndex = 2;
        this.label2.Text = "Try changing the Small Fonts/Large Fonts setting for th" +
            "e computer.";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(244, 138);
        this.Controls.Add(this.label2);
        this.Text = "Form1";
        this.ResumeLayout(false);
    }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }
}