zoukankan      html  css  js  c++  java
  • 设置鼠标可以移动窗体

           #region 设置鼠标可以移动
            private bool ismouseDown = false;//判断是否按下鼠标
            private Point mouseOffset;//记录鼠标坐标
            private void Login_MouseDown(object sender, MouseEventArgs e)
            {
                int xOffset;   //定义X坐标

                int yOffset;   //定义Y坐标

                if (e.Button == MouseButtons.Left)
                {   //如果鼠标的左键点击了,则将坐标分别进行相应的移动

                    xOffset = -e.X;

                    yOffset = -e.Y;

                    mouseOffset = new Point(xOffset, yOffset);

                    ismouseDown = true;   //将mousedowm变量置为true,说明mousedown了

                }

            }

            private void Login_MouseMove(object sender, MouseEventArgs e)
            {
                //如果鼠标移动了

                if (ismouseDown)
                {

                    //获取坐标的位置

                    Point MousePos = Control.MousePosition;

                    MousePos.Offset(mouseOffset.X, mouseOffset.Y);

                    Location = MousePos;  //此时获取的坐标的值即为鼠标的坐标

                }

            }

            private void Login_MouseUp(object sender, MouseEventArgs e)
            {
                //如果鼠标按键松开了,则将mousedown属性置为false,说明鼠标的左键已经松开

                if (e.Button == MouseButtons.Left)

                    ismouseDown = false;

            }
        }
            #endregion

  • 相关阅读:
    聊聊Spark的分区、并行度 —— 前奏篇
    深入探讨HBASE
    分布式流平台Kafka
    GeoServer中使用SLD样式
    OpenLayer修改WFS中的要素
    leaflet加载GeoServer的WFS服务
    OL实现属性查询的功能
    OL3实现空间查询的代码示例
    WFS—GetFeature方法
    OpenLayer+Geoserver+postgis实现路径分析
  • 原文地址:https://www.cnblogs.com/java20130723/p/3211526.html
Copyright © 2011-2022 走看看