制作带有忙碌图标的鼠标(C#)
我有一个需要几秒钟才能运行的应用程序。 是否可以在应用程序处理时使鼠标带有忙碌图标?
I have an application that takes a couple of seconds to run.
Is it possible to make the mouse with the busy icon while the app is processing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 Cursor.WaitCursor 属性。
来源:http:// bytes.com/topic/c-sharp/answers/238623-how-change-mouse-cursor-busy-state
Use Cursor.WaitCursor property.
source: http://bytes.com/topic/c-sharp/answers/238623-how-change-mouse-cursor-busy-state
您需要设置表单的
UseWaitCursor< /code>
属性设置为
true
。 (记得在后面再次将其设置为false
,最好是在finally
块中)您还可以设置
Application.UseWaitCursor
更改为true
以应用它到每一种形式。You need to set the form's
UseWaitCursor
property totrue
. (And remember to set it tofalse
again afterwords, preferably in afinally
block)You can also set
Application.UseWaitCursor
totrue
to apply it to every form.我无法将我的答案作为评论添加到 SLaks 答案中,因此我将其作为答案发布
为了强制应用程序立即将光标设置为等待光标,您必须调用应用程序。设置Application.UseWaitCursor之后的DoEvents()方法,否则在漫长的过程完成后可能会发生变化
I have no option to add my answer as a comment to SLaks answer, so i post it as an answer
In order to force application to set cursor to wait cursor at once, you have to call for Application.DoEvents() method after setting Application.UseWaitCursor, otherwise it might be changed after the lengthy process has been completed
您将需要引用 System.Windows.Forms 来更改光标。
You will need a reference to System.Windows.Forms to change the cursor.