如何延迟鼠标输入矩形的动作c#
我想在鼠标指针进入 winform 图形矩形并在其中停留一段时间后将操作延迟几秒钟。有什么方法可以做到这一点?
感谢
c#、.net 2.0、winform
I would like to delay an action by several seconds after a mouse pointer has entered and remained for period of time in a winform graphics rectangle. What would be a way to do this?
Thanks
c#, .net 2.0, winform
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
诸如此类的事情:
可能可以更有效地完成,但应该可以工作:D
设置 MouseInRectangle -> 的两种方法一种是让它获取当前的鼠标坐标和控件的位置,并查看它是否在其中,另一种方法是在 control.mouse_leave 上将变量设置为 false。
Something such as:
Probably could be done more efficiently, but should work :D
Two ways to set up MouseInRectangle -> one is to make it get the current mouse coordinates and the position of the control and see if it's in it, another way would be a variable which you would set to false on control.mouse_leave.
尝试使用
Timer
控件(System.Windows.Forms.Timer
)。Try using the
Timer
control (System.Windows.Forms.Timer
).请注意 System.Windows.Forms.Timer 并不精确,您不能依赖它会精确地按照给定的时间间隔执行操作。
最好使用 System.Times.timer 并使用 Invoke 操作返回 GUI 线程。
Please notice System.Windows.Forms.Timer is not Exact and you cannot rely it will act on exactly the interval given.
it would be prefeable to use System.Times.timer and use the Invoke action to return to the GUI thread.