zoukankan      html  css  js  c++  java
  • C# winform Panel自定义移动窗口

    ------------恢复内容开始------------

         #region 移动窗口
            [DllImport("user32.DLL", EntryPoint = "ReleaseCapture")]
            private extern static void ReleaseCapture();
    
            [DllImport("user32.DLL", EntryPoint = "SendMessage")]
            private extern static void SendMessage(System.IntPtr hWnd, int wMsg, int wParam, int lParam);
      

         //Panel控件,鼠标点击时移动窗口位置 private void PanelTitle_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(this.Handle, 0x112, 0xf012, 0); } #endregion

      

         #region 托盘双击事件,显示出窗体
            private void notifyIcon1_DoubleClick(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.Show();
                    this.WindowState = FormWindowState.Normal;
                    this.notifyIcon1.Visible = true;
                    this.ShowInTaskbar = true;
                }
            }
            #endregion
    

      

          #region 退出窗体事件
            private void BtnClose_Click(object sender, EventArgs e)
            {
                if (MessageBox.Show("确定是否退出软件?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ==
                    DialogResult.OK)
                {
                    this.Dispose();
                    System.Environment.Exit(System.Environment.ExitCode);
                }
    
            }
            #endregion
    

      

         #region 窗体最小化事件
            private void BtnMin_Click(object sender, EventArgs e)
            {
                if (this.WindowState == FormWindowState.Normal)
                {
                    this.Hide();
                    this.ShowInTaskbar = true;
                    this.notifyIcon1.Visible = true;
                    this.WindowState = FormWindowState.Minimized;
                }
            }
            #endregion
    

      

          #region BtnOpenFile按钮事件
            private void BtnOpenFile_Click(object sender, EventArgs e)
            {
                if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {
                    TxtfoldPath.Text = this.folderBrowserDialog1.SelectedPath;
                }
            }
    
         //鼠标悬停时提示文字信息 private void BtnOpenFile_MouseEnter(object sender, EventArgs e) { ToolTip p = new ToolTip(); p.ShowAlways = true; //是否在鼠标悬浮时提示消息 p.SetToolTip(this.BtnOpenFile, "请选择存放目录"); } #endregion

      

    ------------恢复内容结束------------

    本文来自博客园,作者:云辰,转载请注明原文链接:https://www.cnblogs.com/yunchen/p/13677661.html

  • 相关阅读:
    之前没弄明白的链表和return
    读Bsautiful Soup库有感
    Beautiful Soup库
    XML和JSON的系列操作
    urllib和requests的区别(持续更新)
    request请求把cookie当作参数传入请求
    Python统计文件夹下文件的个数
    基础算法之查找
    timeit用法(不完整)
    spring初识
  • 原文地址:https://www.cnblogs.com/yunchen/p/13677661.html
Copyright © 2011-2022 走看看