闪屏问题 - C# - VS2005
我有一个申请。
首先,我显示一个启动画面,一个表单,这个启动画面将调用另一个表单。
问题:当显示启动画面时,如果我在启动画面顶部打开另一个应用程序,然后最小化这个新打开的应用程序窗口,启动画面会变成白色。 我该如何避免这种情况? 我希望我的启动画面能够清晰显示,并且不受任何应用程序的影响。
I have an application.
First I display a splash screen, a form, and this splash would call another form.
Problem: When the splash form is displayed, if I then open another application on the top of the splash, and then minimize this newly opened application window, the splash screen becomes white. How do I avoid this? I want my splash to be displayed clearly and not affected by any application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在不同的线程中显示启动屏幕 - 当前您的新表单加载代码正在阻塞启动屏幕的 UI 线程。
启动一个新线程,并在该线程上创建启动屏幕并调用
Application.Run(splash)
。 这将在该线程上启动一个新的消息泵。 然后,您需要在准备就绪时将主 UI 线程回调到初始屏幕的 UI 线程(例如使用 Control.Invoke/BeginInvoke),以便初始屏幕可以自行关闭。重要的是确保您不会尝试从错误的线程修改 UI 控件 - 仅使用创建该控件的线程。
You need to display the splash screen in a different thread - currently your new form loading code is blocking the splash screen's UI thread.
Start a new thread, and on that thread create your splash screen and call
Application.Run(splash)
. That will start a new message pump on that thread. You'll then need to make your main UI thread call back to the splash screen's UI thread (e.g. with Control.Invoke/BeginInvoke) when it's ready, so the splash screen can close itself.The important thing is to make sure that you don't try to modify a UI control from the wrong thread - only use the one the control was created on.
.NET 框架对闪屏具有出色的内置支持。 启动一个新的WF项目,Project + Add Reference,选择Microsoft.VisualBasic。 添加一个新表单,将其命名为 frmSplash。 打开 Project.cs 并使其看起来像这样:
The .NET framework has excellent built-in support for splash screens. Start a new WF project, Project + Add Reference, select Microsoft.VisualBasic. Add a new form, call it frmSplash. Open Project.cs and make it look like this:
我有一个类似的问题,你可能想检查一下。 我的 Stack Overflow 答案 非常适合我 - 你可能想要采纳看看。
I had a similar issue you might want to check out. The Stack Overflow answer I got worked perfectly for me - you may want to take a look.