none
c#中void point Offset(point)方法具体怎样? RRS feed

  • 问题

  • 比如这里:  //鼠标按下时
            private void picImage_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button ==MouseButtons .Left )
                {
                    isMouseDown = true;
                    mouseOffset = new Point(-e.X, -e.Y);//设置平移量
                }
            }
            //鼠标移动时
            private void picImage_MouseMove(object sender, MouseEventArgs e)
            {
                if (isMouseDown )
                {
                    Point mousePos = Control.MousePosition;
                    mousePos.Offset(mouseOffset.X, mouseOffset.Y);
                    this.Location = mousePos;
                }
            }

    以上代码中, mouseOffset = new Point(-e.X, -e.Y);//设置平移量

    为什么加个负号才能正确移动?

     

    2011年2月8日 2:40

答案