如何建立一个启动画面到Windows窗体应用程序没有设置定时器等? [英] How do I build a splash screen into a Windows Forms application without setting timers etc?

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

问题描述

我要显示一个启动画面,而我的应用程序的主要形式加载和飞溅的形式应该消失无我有打造定时器等。另一个重要的事情是主要的形式应该是一个确定的应用程序退出时,当我用我泼的形式来启动应用程序,然后用它来打开我的主要形式,我不能处置闪屏,因为这将杀死应用程序。

解决方案

 使用Microsoft.VisualBasic.ApplicationServices;

公共类启动:WindowsFormsApplicationBase
{
    保护覆盖无效OnCreateSplashScreen()
    {
        闪屏=新SplashForm();
    }

    保护覆盖无效OnCreateMainForm()
    {
        MainForm的=新MyMainForm();
    }
}

静态类节目
{
    静态无效的主要(字串[] args)
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(假);
        新启动()运行(参数)。
    }
}
 

I want to show a splash screen while my application's main form is loading and the splash form should disappear without me having to build in timers etc. Another important thing is that the main form should be the one determining when the application exits, when I use my splash form to start the application and then use it to open my main form I cannot dispose the splash screen, since that will kill the application.

解决方案

using Microsoft.VisualBasic.ApplicationServices;

public class Startup : WindowsFormsApplicationBase
{
    protected override void OnCreateSplashScreen()
    {
        SplashScreen = new SplashForm();
    }

    protected override void OnCreateMainForm()
    {
        MainForm = new MyMainForm();
    }
}

static class Program
{
    static void Main(string[] args)
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        new Startup().Run(args);
    }
}

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

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