Exemplo n.º 1
0
 /// <summary>
 /// 鼠标移动事件:让控件跟着鼠标移动
 /// </summary>
 void FrameControl_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         this.Visible = false;
         MoveControl.DrawDragBound(baseControl);
         ControlMove();
     }
     else
     {
         this.Visible = true;
         SetCursorShape(e.X, e.Y); //更新鼠标指针样式
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 鼠标移动事件:让控件跟着鼠标移动
        /// </summary>
        void MouseMove(object sender, MouseEventArgs e)
        {
            Cursor.Current = Cursors.SizeAll; //当鼠标处于控件内部时,显示光标样式为SizeAll

            //当鼠标左键按下时才触发
            if (e.Button == MouseButtons.Left)
            {
                MoveControl.DrawDragBound(this.currentControl);
                if (fc != null)
                {
                    fc.Visible = false;   //先隐藏
                }
                cPoint = Cursor.Position; //获得当前鼠标位置
                int x = cPoint.X - pPoint.X;
                int y = cPoint.Y - pPoint.Y;
                currentControl.Location = new Point(currentControl.Location.X + x, currentControl.Location.Y + y);
                pPoint = cPoint;
            }
        }