当用户按住左键时,如何强制鼠标沿着特定轴线移动?我希望用户能够沿着X轴移动鼠标,而在Y轴上任何移动都将被“取消”。
谢谢 Eden
当用户按住左键时,如何强制鼠标沿着特定轴线移动?我希望用户能够沿着X轴移动鼠标,而在Y轴上任何移动都将被“取消”。
谢谢 Eden
请查看此链接:http://social.msdn.microsoft.com/Forums/en/wpf/thread/9b07abce-bb32-4cd1-9ae5-d34973d5cc95
链接内容如下:
public partial class MouseOperations
{
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SetCursorPos")]
[return:System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool SetCursorPos(int X, int Y);
}
你需要从Mouse.MouseMove事件处理程序中调用该方法。
MouseOperations.SetCursorPos(xAxisPosition,0);