void GuiFrame_MouseMove(object sender, MouseEventArgs e) { //this.baseControl.Parent.Refresh(); if (e.Button == MouseButtons.Left) { this.Visible = false; MoveGui.DrawDragBound(baseControl); ControlMove(); } else { this.Visible = true; SetCursorShape(e.X, e.Y); //更新鼠标指针样式 } //this.baseControl.Parent.Update(); }
/// <summary> /// 鼠标移动事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void MouseMove(object sender, MouseEventArgs e) { Cursor.Current = Cursors.SizeAll; //当鼠标处于控件内部时,鼠标样式为SizeAll if (e.Button == MouseButtons.Left) { MoveGui.DrawDragBound(this.CurrentControl); if (fc != null) { fc.Visible = false; //隐藏 } cPoint = Cursor.Position; //记录鼠标当前坐标位置 int x = cPoint.X - pPoint.X; //得到x坐标的位移值 int y = cPoint.Y - pPoint.Y;; //得到y坐标的位移值 //CurrentControl.Refresh(); CurrentControl.Location = new Point(CurrentControl.Location.X + x, CurrentControl.Location.Y + y); pPoint = cPoint; } }