zoukankan      html  css  js  c++  java
  • 当窗口的formBorderStyle设置为None时,如何实现窗体拖动

    private Point mouseOffset;        //记录鼠标指针的坐标
            private bool isMouseDown = false//记录鼠标按键是否按下
     
            private void picCLose_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
     
            private void fmLogin_MouseDown(object sender, MouseEventArgs e)
            {
                int xOffset;
                int yOffset;
     
                if (e.Button == MouseButtons.Left)
                {
                    xOffset = -e.X - SystemInformation.FrameBorderSize.Width;
                    yOffset = -e.Y - SystemInformation.CaptionHeight -
                     SystemInformation.FrameBorderSize.Height;
                    mouseOffset = new Point(xOffset, yOffset);
                    isMouseDown = true;
                }
            }
     
            private void fmLogin_MouseMove(object sender, MouseEventArgs e)
            {
                if (isMouseDown)
                {
                    Point mousePos = Control.MousePosition;
                    mousePos.Offset(mouseOffset.X+5, mouseOffset.Y+30);
                    Location = mousePos;
                }
            }
     
            private void fmLogin_MouseUp(object sender, MouseEventArgs e)
            {
                // 修改鼠标状态isMouseDown的值
                // 确保只有鼠标左键按下并移动时,才移动窗体
                if (e.Button == MouseButtons.Left)
                {
                    isMouseDown = false;
                }
            }
  • 相关阅读:
    poj3537--Crosses and Crosses
    poj3480--John
    poj2975--Nim
    poj2960 S-Nim
    poj2505-A multplication game
    Team Queue(POJ 2259)
    将caffemodel文件转换为Matlab可用的数据形式
    Invalid MEX-file: caffe.mexa64 的解决方案
    mongoDB-3.x启用认证
    mongoDB跨平台图形管理工具
  • 原文地址:https://www.cnblogs.com/gengxin/p/5322930.html
Copyright © 2011-2022 走看看