代码:
private void Form1_MouseWheel(object sender, MouseEventArgs e)
{
if (leave == true)
{
timer1.Interval = 10;
}
}
我想这样做,如果我将鼠标滚轮向下转动,它会减慢计时器并增加间隔时间,如果我向上转动鼠标滚轮,它会减少间隔时间。
我该怎么做?
使用MouseEventArgs.Delta
属性(property)
The mouse wheel combines the features of a wheel and a mouse button. The wheel has discrete, evenly spaced notches. When you rotate the wheel, a wheel message is sent as each notch is encountered. One wheel notch, a detent, is defined by the windows constant WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward (away from the user); a negative value indicates that the wheel was rotated backward (toward the user).
private void Form1_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta > 0) //moved forward
{
timer1.Interval += 1000;
}
else //moved backword
{
timer1.Interval -= 1000;
}
}
我是一名优秀的程序员,十分优秀!