日期:2014-05-20 浏览次数:21024 次
namespace WindowsFormsApplication1
{
    public struct CPoint
    {
        public int x;
        public int y;
    }
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int Pages = 10;
        CPoint pStart,pEnd;
        int IgnoreX = 5;//当鼠标X方向移动位置小于这个值的时候,表示没有滚动
        int IgnoreY = 5;//当鼠标Y方向移动位置小于这个值的时候,表示没有滚动
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            pStart.x = e.X;
            pStart.y = e.Y;
        }
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            pEnd.x = e.X;
            pEnd.y = e.Y;
            int MoveX = System.Math.Abs(pEnd.x - pStart.x);
            int MoveY = System.Math.Abs(pEnd.y - pStart.y);
            if ((pEnd.x < pStart.x) && (MoveX > IgnoreX))//向左滚动,表示下一页
            {
                Pages++;
                if (Pages> 10) Pages = 0;
                string strMsg = string.Format("当前低{0}页",Pages);
                MessageBox.Show(strMsg);
                return;
            }
            else
            {
                Pages--;
                if (Pages < 0) Pages = 10;
                string strMsg = string.Format("当前低{0}页", Pages);
                MessageBox.Show(strMsg);
                return;
            }
                   
            if((pEnd.y > pStart.y) && (MoveY >IgnoreY))//向下滚动,上一页
            {
                Pages--;
                if (Pages < 0) Pages = 10;
                string strMsg = string.Format("当前低{0}页", Pages);
                MessageBox.Show(strMsg);
                return;
            }else
            {
                Pages++;
                if (Pages > 10) Pages = 0;
                string strMsg = string.Format("当前低{0}页", Pages);
                MessageBox.Show(strMsg);
                return;
            }
 
        }
    }
}
------解决方案--------------------
很简单
------解决方案--------------------
我也不会,学习
------解决方案--------------------
来看看头像