centeredform.cs

来自「window mobile 中非全屏显示对话框」· CS 代码 · 共 40 行

CS
40
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace NonFullscreenDemo
{
  public partial class CenteredForm : NonFullscreenForm
  {
    private SizeF MyAutoScaleFactor;

    public CenteredForm()
    {
      InitializeComponent();

      MyAutoScaleFactor = new SizeF(
        this.AutoScaleDimensions.Width / 96F,
        this.AutoScaleDimensions.Height / 96F);

      this.Height = (int)(MyAutoScaleFactor.Height * 80 - SystemInformation.MenuHeight);
    }

    private void btnExpand_Click(object sender, EventArgs e)
    {
      if (btnExpand.Text == "Expand")
      {
        btnExpand.Text = "Collapse";
        this.Height = (int)(MyAutoScaleFactor.Height * 146);
      }
      else
      {
        btnExpand.Text = "Expand";
        this.Height = (int)(MyAutoScaleFactor.Height * 80);
      }
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?