关闭

实现winform 中的分割窗体效果

标签: winformcomponentsobjectresourceswindowssystem
2049人阅读 评论(0) 收藏 举报

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace 分割窗体
{
 /// <summary>
 /// Form1 的摘要说明。
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  private System.Windows.Forms.PictureBox pictureBox1;
  private System.Windows.Forms.Splitter splitter1;
  private System.Windows.Forms.PictureBox pictureBox2;
  private System.Windows.Forms.NotifyIcon notifyIcon1;
  private System.Windows.Forms.ContextMenu contextMenu1;
  private System.Windows.Forms.MenuItem menuItem1;
  private System.Windows.Forms.MenuItem menuItem2;
  private System.Windows.Forms.MenuItem menuItem3;
  private System.ComponentModel.IContainer components;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <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()
  {
   this.components = new System.ComponentModel.Container();
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
   this.pictureBox1 = new System.Windows.Forms.PictureBox();
   this.splitter1 = new System.Windows.Forms.Splitter();
   this.pictureBox2 = new System.Windows.Forms.PictureBox();
   this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
   this.contextMenu1 = new System.Windows.Forms.ContextMenu();
   this.menuItem1 = new System.Windows.Forms.MenuItem();
   this.menuItem2 = new System.Windows.Forms.MenuItem();
   this.menuItem3 = new System.Windows.Forms.MenuItem();
   this.SuspendLayout();
   //
   // pictureBox1
   //
   this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Left;
   this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
   this.pictureBox1.Location = new System.Drawing.Point(0, 0);
   this.pictureBox1.Name = "pictureBox1";
   this.pictureBox1.Size = new System.Drawing.Size(100, 266);
   this.pictureBox1.TabIndex = 0;
   this.pictureBox1.TabStop = false;
   //
   // splitter1
   //
   this.splitter1.Location = new System.Drawing.Point(100, 0);
   this.splitter1.Name = "splitter1";
   this.splitter1.Size = new System.Drawing.Size(3, 266);
   this.splitter1.TabIndex = 1;
   this.splitter1.TabStop = false;
   //
   // pictureBox2
   //
   this.pictureBox2.Dock = System.Windows.Forms.DockStyle.Fill;
   this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
   this.pictureBox2.Location = new System.Drawing.Point(103, 0);
   this.pictureBox2.Name = "pictureBox2";
   this.pictureBox2.Size = new System.Drawing.Size(441, 266);
   this.pictureBox2.TabIndex = 2;
   this.pictureBox2.TabStop = false;
   //
   // notifyIcon1
   //
   this.notifyIcon1.ContextMenu = this.contextMenu1;
   this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
   this.notifyIcon1.Text = "notifyIcon1";
   this.notifyIcon1.Visible = true;
   //
   // contextMenu1
   //
   this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                       this.menuItem1,
                       this.menuItem2,
                       this.menuItem3});
   //
   // menuItem1
   //
   this.menuItem1.Index = 0;
   this.menuItem1.Text = "显示";
   this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
   //
   // menuItem2
   //
   this.menuItem2.Index = 1;
   this.menuItem2.Text = "隐藏";
   this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
   //
   // menuItem3
   //
   this.menuItem3.Index = 2;
   this.menuItem3.Text = "退出";
   this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(544, 266);
   this.Controls.Add(this.pictureBox2);
   this.Controls.Add(this.splitter1);
   this.Controls.Add(this.pictureBox1);
   this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
   this.MaximumSize = new System.Drawing.Size(552, 300);
   this.MinimumSize = new System.Drawing.Size(552, 300);
   this.Name = "Form1";
   this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
   this.Text = "分割窗体and状态区";
   this.Load += new System.EventHandler(this.Form1_Load);
   this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

  private void menuItem1_Click(object sender, System.EventArgs e)
  {
   this.Show();
  }

  private void menuItem2_Click(object sender, System.EventArgs e)
  {
   this.Hide();
  }

  private void menuItem3_Click(object sender, System.EventArgs e)
  {
   this.Close();
  }

  private void Form1_Load(object sender, System.EventArgs e)
  {
  
  }
 }
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:20969次
    • 积分:319
    • 等级:
    • 排名:千里之外
    • 原创:10篇
    • 转载:7篇
    • 译文:0篇
    • 评论:2条
    文章存档
    最新评论