Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Application Context

A friend of mine has just started getting into .NET development using Windows Forms.  He asked me how he should go about creating a splash screen for his application.  I told him about the ApplicationContext class and that this is the way I would go about it.

I would do something like the following:

using System;
using System.Windows.Forms;
namespace Stahlhood.Windows.Forms {
    public class MyApplicationContext : ApplicationContext {
        //
        //    Member Field(s)
        //
        
// SplashForm would be a windows form in your project // with all your splash screen goodness. private SplashForm splashForm;
// MainForm would be a windows form in your project // that is basically the umm Main Form.. private MainForm mainForm;
// // Constructor(s) // public MyApplicationContext() { splashForm = new SplashForm(); splashForm.Closed += new EventHandler(OnFormClosed); this.MainForm = splashForm; }
// // Event Method(s) // private void OnFormClosed(object sender, EventArgs e) { SplashForm splashForm = sender as SplashForm; if (splashForm != null) { this.MainForm = new MainForm(); this.MainForm.Show(); } // if }
/// <summary> /// The main entry point for the application.</summary> [STAThread] static void Main() { // Enable XP Visual Styles Application.EnableVisualStyles(); Application.Run(new MyApplicationContext()); } } }
Is this the way most of you Windows Forms guys do this?  I would like your thoughts on different approaches.

No Comments