1.高位字,署名:
((short)(wParam>>16))
2. 为了获得最大的清晰,我会定义一组这样的函数:
internal static class NativeMethods
{
internal static ushort HIWORD(IntPtr dwValue)
{
return (ushort)((((long)dwValue) >> 0x10) & 0xffff);
}
internal static ushort HIWORD(uint dwValue)
{
return (ushort)(dwValue >> 0x10);
}
internal static int GET_WHEEL_DELTA_WPARAM(IntPtr wParam)
{
return (short)HIWORD(wParam);
}
internal static int GET_WHEEL_DELTA_WPARAM(uint wParam)
{
return (short)HIWORD(wParam);
}
}
并且,像这样,这里的函数wParam
是WPARAM
你处理的Win32得到WM_MOUSEWHEEL
或WM_MOUSEHWHEEL
消息:
int zDelta = NativeMethods.GET_WHEEL_DELTA_WPARAM(wParam);
您可能需要抑制,从而溢出检查这个才能正常工作。要做到这一点,要么改变你的项目设置 CodeGo.net,或包裹在一个相关的转换函数unchecked
。
3.获取一个值,该值指示该轮已经改变量。
private void MouseWheelHandler(object sender, MouseWheelEventArgs e) { if (e.Delta > 0) { // Do one thing } else if (e.Delta < 0) { // Do the other thing } }
http://codego.net/8857081/