停止鼠标光标水平移动,但仍想捕获 MouseMove 事件
在我的 winforms 应用程序中,我有一个打开下拉菜单的功能,您可以向左或向右移动光标来选择一个子选项。但是,我不想移动光标,我只想让子选项本身向左或向右移动(取决于鼠标尝试移动的方向)。我希望这对你有意义。
有谁知道如何阻止光标向特定方向移动,同时仍然能够在用户“移动”鼠标时捕获 mousemove 事件?
任何帮助表示感谢,谢谢!
In my winforms app, I have a feature that opens a dropdown menu, and you move your cursor left or right to select a sub-option. But, I don't want the cursor to move, I just want the sub-options them selves to move left or right (depending on which direction the mouse is trying to move in). I hope this makes sense to you.
Does anyone know how to stop the cursor from moving in a particular direction, while still being able to capture mousemove events while the user "moves" the mouse?
Any help is appreciated, Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不应该尝试实现这一点,因为它违反了所有用户界面标准并且只会让用户感到困惑。鼠标应该能够移动到哪里并不由您的应用程序来决定。如果您想实现允许导航选择的其他方式,那么我建议您研究其他选项。
You should not try to implement this, as it breaks all user interface standards and will just confuse the user. It's not up to your application to decide where the mouse should be able to move. If you want to implement some other way of allowing navigation selection then I would suggest investigating other options.
我认为你根本不应该实施这样的解决方案。
但是,您可以将鼠标光标位置设置回其在 MouseMove Handler 中的原始位置。但是您必须先删除处理程序,然后再设置回位置并在此之后再次添加它们。您可以通过 pInvoke 设置鼠标位置。如何做到这一点,您可以在这里找到 http://pinvoke.net/default.aspx/user32。鼠标事件
I don't think you should implement such a solution at all.
But well, you could set the mouse cursor position back to its original position within the MouseMove Handler. But you have to remove the handler before setting back the position and adding them again after this. You can set the Mouse position via pInvoke. How to do that, you can find here http://pinvoke.net/default.aspx/user32.mouse_event
您可以手动设置光标位置
You can set Cursor position manualy