无法确定条件表达式的类型,因为“short”和“int”可相互隐式转换,求解
MouseLLHookStruct mouseHookStruct =
(MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));
MouseButtons button = GetButton(wParam);
MouseEventType eventType = GetEventType(wParam);
MouseEventArgs e = new MouseEventArgs(
button,
(eventType == MouseEventType.DoubleClick ? 2 : 1),
mouseHookStruct.pt.x,
mouseHookStruct.pt.y,
(eventType == MouseEventType.MouseWheel ? (short)((mouseHookStruct.mouseData >> 16) & 0xffff) : 0));
最后这一句在vs2010里正常在vs2005里面出现错误:无法确定条件表达式的类型,因为“short”和“int”可相互隐式转换.如果把short改成int程序会出现不正常点击无效。
求高手该如何修正一下。
------解决方案--------------------因为 (short)((mouseHookStruct.mouseData >> 16) & 0xffff) : 0
你前面是一个short,后面是一个int
默认的整形是int(Int32),浮点型式double。
0改为(short)0