日期:2014-05-18  浏览次数:20908 次

如何计算鼠标两次单击的时间间隔啊?在线等啊
如题 用什么函数 或者大家有没有相关的代码
谢谢拉

------解决方案--------------------
你可以使用C#中的StopWatch类来实现,MSDN查一下用法就知道了。
示例:
StopWatch myStopWatch=new StopWatch();

....
myStopWatch.Start();
....
myStopWatch.Stop;
....
------解决方案--------------------
up
------解决方案--------------------
首先计算开始时间,然后计算结束时间,然后相减,就可以了/
------解决方案--------------------
感觉自己算时间的话总有些别扭,可以查一下有没有可以用的API.
------解决方案--------------------
C# code

        private bool isPressed;
        public static long time;
        public static long timePassed;
        private void button2_Click(object sender, EventArgs e)
        {
            if (isPressed)
            {
                time = Environment.TickCount - timePassed;
                timePassed = Environment.TickCount;
            }
            else
            {
                isPressed = true;
                time = 0;
                timePassed = Environment.TickCount;
            }
            MessageBox.Show("距离上一次单击该按钮时隔:" + time.ToString() + "毫秒");
        }