“永久”隐藏 WinForms 光标?
我正在开发一个全屏应用程序,其中包含一些动画表单控件(基本上是移动的标签)。
我想在一段时间不活动后隐藏光标,并且我尝试使用此线程中给出的方法: 空闲时间后隐藏鼠标光标
虽然这在某种意义上有效,但表单计时器甚至不会开始计数,直到表单不再有更新(对我的需要来说无用)。 此外,一旦光标被隐藏,当控件被移动时它会重新显示(即标签之一被动画化)。
我需要的是 Windows 忽略显示器本身发生的任何情况,只听从我的“Cursor.Hide()”和“Cursor.Show()”调用。 我尝试使用普通的线程计时器,但这根本不起作用 - 光标甚至没有隐藏。
所以我想我要求的是一种隐藏光标的方法,同时允许在不重新显示光标的情况下发生动画。
任何帮助深表感谢。 汤姆
I am developing a full-screen application which contains some animated Forms controls (basically, labels which move).
I want to hide the cursor after a period of inactivity, and I have tried using the method given in this thread: Hide mouse cursor after an idle time
While this works in a sense, the Forms timer does not even begin counting until the form has no more updates (useless for my needs). Additionally, once the cursor is hidden, it is re-shown when a control is moved (i.e one of the labels is animated).
What I need is for Windows to ignore whatever is going on with the display itself, and just obey my 'Cursor.Hide()' and 'Cursor.Show()' calls. I tried using a normal Threading Timer, but this didn't work at all - the cursor didn't even hide.
So I guess what I'm asking for is a way to hide the cursor whilst allowing animations to take place without re-showing the cursor.
Any help is much appreciated.
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
线程计时器方法调用不会在创建它们的线程上执行,因此要使调用正常工作,您必须通过 UI 线程上的调用来进行这些调用。
Threading timer method calls don't execute on the thread that created them so for the calls to work, you'd have to make those calls via an invoke on the UI thread.
猜测一下,为什么不打开一个开关来处理 wndproc 中与鼠标相关的所有 WM_ 消息,而不执行任何操作。 关闭时,进行 WM_ 鼠标消息的正常处理。
A guess, why not have a toggle on which will just handle all WM_ messages which are related to mouse in a wndproc and just do nothing. On toggle off, let the normal processing of WM_ mouse messages take place.
似乎有一个错误 http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/2b963082-c5a7-469c-ba35-02b4a546f913/
您可以尝试的是将自己的自定义光标分配为 100 % 透明位图 - 看起来没有光标。
There seem to be a bug http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/2b963082-c5a7-469c-ba35-02b4a546f913/
What you could possibly try is to assign own custom cursor with 100% transparent bitmap - that looks like there is no cursor.