zoukankan      html  css  js  c++  java
  • winform FormBordStyle=none 及 wpf FormBordStyle=none 的鼠标点击移动问题

    winform:

    private Point mPoint;

    /// <summary>
            /// 鼠标按下
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void panel1_MouseDown(object sender, MouseEventArgs e)
            {
                mPoint = new Point(e.X, e.Y);
            }
    
            /// <summary>
            /// 鼠标移动
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void panel1_MouseMove(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    this.Location = new Point(this.Location.X + e.X - mPoint.X, this.Location.Y + e.Y - mPoint.Y);
                }
            }

    //bool formMove = false;//窗体是否移动
    //Point formPoint;//记录窗体的位置

    private void Login_MouseDown(object sender, MouseEventArgs e)
    {
    //formPoint = new Point();

    //int xOffset;
    //int yOffset;
    //if (e.Button == MouseButtons.Left)
    //{
    // xOffset = -e.X - SystemInformation.FrameBorderSize.Width;
    // yOffset = -e.Y - SystemInformation.CaptionHeight - SystemInformation.FrameBorderSize.Height;
    // formPoint = new Point(xOffset, yOffset);
    // formMove = true;//开始移动
    //}
    }

    private void Login_MouseMove(object sender, MouseEventArgs e)
    {
    //if (formMove == true)
    //{
    // Point mousePos = Control.MousePosition;
    // mousePos.Offset(formPoint.X, formPoint.Y);
    // Location = mousePos;
    //}
    }

    private void Login_MouseUp(object sender, MouseEventArgs e)
    {
    //if (e.Button == MouseButtons.Left)//按下的是鼠标左键
    //{
    // formMove = false;//停止移动
    //}
    }

    wpf的移动:

    private void Login_MouseDown(object sender, MouseEventArgs e)
    {
    //if (e.LeftButton == MouseButtonState.Pressed)
    //{
    // DragMove();
    //}

    }

    只想一个人飞----奔跑的孩子
    个人博客地址:http://www.microyang.cn
  • 相关阅读:
    linux rcu
    linux下的进程、网络、性能监控命令
    使用optimizely做A/B测试
    使用logstash收集日志的可靠性验证
    LAMP-HTTPD的安装全步骤
    Iptables Save
    linux-ftp
    远程桌面验证问题,函数错误-windows
    ESXIroot密码重置
    centos or windows 双系统
  • 原文地址:https://www.cnblogs.com/liyangLife/p/3598789.html
Copyright © 2011-2022 走看看