日期:2014-05-20  浏览次数:20831 次

winform能不能实现按android或者iphone手机那样的主界面滑动效果呢
如题! 可以的话谁给个例子我谢谢了哈 ! 本人邮箱 hanwu5728@126.com

我现在想做一个分页的效果触摸(手指滑动方向)就实现上 、下页的显示!

------解决方案--------------------
这个主要就是查看鼠标的动作了,使用API BOOL GetCursorPos(
LPPOINT lpPoint // address of structure for cursor position
);
分别记录按下时候鼠标的坐标,和移动的时候的坐标,松开鼠标的时候计算这两个坐标的差值,你就知道应该往前一页还是往后一页。
------解决方案--------------------
直接处理MouseDown,MouseUp,MouseMove就可以了。
------解决方案--------------------
楼上的 都看懂了 他说的是手指滑动方向 跟MouseDown有毛关系

这个貌似需要算法 不管你会不会 反正我不会
------解决方案--------------------
C# code

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;
            }
 
        }
    }
}

------解决方案--------------------
很简单

------解决方案--------------------
我也不会,学习
------解决方案--------------------
来看看头像