闪屏问题 - C# - VS2005 [英] problem with splash screen - C# - VS2005

查看:34
本文介绍了闪屏问题 - C# - VS2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个申请.

首先我显示一个闪屏,一个表单,这个闪屏会调用另一个表单.

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.

推荐答案

您需要在不同的线程中显示启动画面 - 当前您的新表单加载代码正在阻塞启动画面的 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.

启动一个新线程,然后在该线程上创建启动画面并调用 Application.Run(splash).这将在该线程上启动一个新的消息泵.然后,您需要让主 UI 线程在准备好时回调到初始屏幕的 UI 线程(例如,使用 Control.Invoke/BeginInvoke),以便初始屏幕可以自行关闭.

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.

重要的是确保您不会尝试从错误的线程修改 UI 控件 - 仅使用创建控件的那个.

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.

这篇关于闪屏问题 - C# - VS2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆