zoukankan      html  css  js  c++  java
  • Winform窗体拖动

    private void panelControl1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Left)
                {
                    currentFormWidth = this.Width;
                    currentFormWidth = this.Height;
                    isMouseDown = true;
                    mouseOffset = new Point(MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y);
                    this.Cursor = Cursors.SizeAll;
                }
            }
    
            private void panelControl1_MouseEnter(object sender, EventArgs e)
            {
                isMouseEnter = true;
            }
    
            private void panelControl1_MouseLeave(object sender, EventArgs e)
            {
                Point p = MousePosition;
                if (p.X - 10 <= this.Left || p.X + 10 >= this.Left + currentFormWidth || p.Y - 10 <= this.Top || p.Y + 10 >= this.Bottom)
                {
                    isMouseEnter = false;
                }
            }
    
            private void panelControl1_MouseMove(object sender, MouseEventArgs e)
            {
                if (isMouseDown == true)
                {
                    Point old = this.Location;
                    this.Location = getMiniBallMoveLocation();
                }
            }
    
            private void panelControl1_MouseUp(object sender, MouseEventArgs e)
            {
                isMouseDown = false;
                this.Cursor = Cursors.Default;
            }
    
            private Point getMiniBallMoveLocation()
            {
                int x = MousePosition.X - mouseOffset.X;
                int y = MousePosition.Y - mouseOffset.Y;
                return new Point(x, y);
            }
  • 相关阅读:
    sudo 做不到的事
    Oracle 用户操作表权限
    CentOS7.2 使用Shell安装Oracle12c
    package-cleanup
    glibc-commons 依赖解析 版本错误,xxx is duplicate yyy
    Centos7.2 编译安装方式搭建 phpMyAdmin
    Jenkins 环境搭建
    awk 使用案例
    Linux文件系统
    用python写一个计算器
  • 原文地址:https://www.cnblogs.com/Xamarin-Oz/p/11254386.html
Copyright © 2011-2022 走看看