📄 viceform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace DoubleWindows
{
/// <summary>
/// ViceForm 的摘要说明。
/// </summary>
public class ViceForm : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
/// <summary>
/// 构造函数。在构造副窗口时应传入主窗口句柄以便于副窗口对主窗口进行操作。
/// </summary>
/// <param name="mainForm">主窗口的句柄。</param>
public ViceForm(MainForm mainForm)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
this.mainForm = mainForm;
Rectangle rect = Screen.GetWorkingArea(this);
this.Top = 0;
this.Left = rect.Width / 2;
this.Height = rect.Height;
this.Width = rect.Width / 2;
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// ViceForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "ViceForm";
this.Text = "窗口B";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ViceForm_KeyDown);
this.Resize += new System.EventHandler(this.ViceForm_Resize);
}
#endregion
/// <summary>
/// 主窗口的句柄。
/// </summary>
private MainForm mainForm;
private void ViceForm_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
//当按下F1键时,打开或关闭副窗口,并设置两个窗口的大小。
mainForm.DoubleWindowsForm_KeyDown(sender, e);
}
private void ViceForm_Resize(object sender, System.EventArgs e)
{
//窗口大小发生变化时,调整窗口的大小。
if (this.Focused)
mainForm.Width = this.Left - mainForm.Left;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -