码迷,mamicode.com
首页 > 移动开发 > 详细

formborderstyle设为none之后怎么移动窗体?

时间:2014-09-12 01:07:02      阅读:263      评论:0      收藏:0      [点我收藏+]

标签:style   io   os   ar   for   sp   on   c   new   

        bool formMove = false;//窗体是否移动
        Point formPoint=new Point();//记录窗体的位置
        int x;
        int y;
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                x = e.X;
                y = e.Y;
                formMove = true;//开始移动
            }
        }
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (formMove == true)
            {
                formPoint.X = Control.MousePosition.X - x;
                formPoint.Y = Control.MousePosition.Y - y;
                Location = formPoint;
            }
        }
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)//按下的是鼠标左键
            {
                formMove = false;//停止移动
            }
        }

formborderstyle设为none之后怎么移动窗体?

标签:style   io   os   ar   for   sp   on   c   new   

原文地址:http://www.cnblogs.com/danjie/p/3967488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!