Cod*_*ray 7

为了最大限度地清晰起见,我将定义一组这样的函数:

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

然后使用像这样的函数,从处理Win32 或消息获得wParamWPARAM参数在哪里:WM_MOUSEWHEELWM_MOUSEHWHEEL

int zDelta = NativeMethods.GET_WHEEL_DELTA_WPARAM(wParam);
Run Code Online (Sandbox Code Playgroud)

您可能需要禁止溢出检查才能使其正常工作.要执行此操作,请更改项目设置,或将相关的转换函数包装在unchecked块中.


ras*_*mus 2

高位字,签名:

 ((short)(wParam>>16))
Run Code Online (Sandbox Code Playgroud)