如何建立在Windows窗体应用程序启动画面? [英] How to build splash screen in windows forms application?

查看:216
本文介绍了如何建立在Windows窗体应用程序启动画面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示启动画面在我的应用程序启动几秒钟。有谁知道如何实现这一点?

I need to show splash screen on my application start for few seconds. Does anybody know how to implement this?

将成为帮助非常AP preciate。

Will be much appreciate for the help.

推荐答案

首先,创建你的闪屏作为一个无国界的,不可移动的形式与它的图像,设置初始显示在屏幕中央,彩色​​的方式,你想。所有这一切都可以从设计者内设置;具体而言,您希望:

First, create your splash screen as a borderless, immovable form with your image on it, set to initially display at the center of the screen, colored the way you want. All of this can be set from within the designer; specifically, you want to:


  • 设置窗体的控制框,MaximizeBox,MinimizeBox和ShowIcon属性设置为假

  • 将中StartPosition属性设置为中心屏幕

  • 将FormBorderStyle属性为无

  • 设置窗体的和的minimumSize向MAXIMUMSIZE是相同的初始大小。

然后,你需要决定在哪里展示,并在那里将其关闭。这两个任务需要在你的程序的主启动逻辑的两侧发生。这可能是你的应用程序的main()函数,或者可能在主应用程序窗体的Load处理程序;无论你正在创建大型昂贵的对象,从硬盘驱动器读取设置,一般服药时间长的主应用程序屏幕前做幕后的东西。

Then, you need to decide where to show it and where to dismiss it. These two tasks need to occur on opposite sides of the main startup logic of your program. This could be in your application's main() routine, or possibly in your main application form's Load handler; wherever you're creating large expensive objects, reading settings from the hard drive, and generally taking a long time to do stuff behind the scenes before the main application screen displays.

然后,你所要做的就是创建表单,显示()它的一个实例,并保持对它的引用,而你做你的启动初始化。一旦你的主要形式加载,关闭()吧。

Then, all you have to do is create an instance of your form, Show() it, and keep a reference to it while you do your startup initialization. Once your main form has loaded, Close() it.

如果您的闪屏上是否会有动画图像,窗口将需要双缓冲,以及,你需要绝对确保所有初始化逻辑发生在GUI线程之外(这意味着你不能有在MainForm中的负载处理你的主要装载的逻辑;你必须创建一个BackgroundWorker或其他一些常规的螺纹

If your splash screen will have an animated image on it, the window will need to be "double-buffered" as well, and you will need to be absolutely sure that all initialization logic happens outside the GUI thread (meaning you cannot have your main loading logic in the mainform's Load handler; you'll have to create a BackgroundWorker or some other threaded routine.

这篇关于如何建立在Windows窗体应用程序启动画面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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