开发者

Forcing mouse movement along specific axis in WPF

How can I force the mouse to move along a specific axis while the user keeps the left button down? I would like the user to be able to move the mouse along the X axis w开发者_开发问答hile any movement on the Y axis would be "canceled".

thanks Eden


Check this: http://social.msdn.microsoft.com/Forums/en/wpf/thread/9b07abce-bb32-4cd1-9ae5-d34973d5cc95

From the link:

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); 
} 

You'll have to call the method from the Mouse.MouseMove event handler.

MouseOperations.SetCursorPos(xAxisPosition,0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜