Skip to main content
A newer version of this page is available. .

Use a Custom Class to Show a Splash Form

  • 3 minutes to read

This topic demonstrates how create a custom splash form and use a custom class to show this form.

Tip

A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/e4646/how-to-use-a-custom-form-as-a-splash-screen.

  1. Create a new Windows Form in your solution’s WinForms Application project, name the form SplashScreenForm, and design it to meet your requirements.

    Splash

  2. Add a new class to your WinForms Application Project and implement the ISplash interface.

    • Override the ISplash.Start method. Create a SplashScreenForm instance and call the form’s Show method.
    • In the ISplash.Stop method’s override, hide and close the SplashScreenForm.
    • The ISplash.IsStarted property indicates whether the SplashScreenForm is shown.
    • Override ISplash.SetDisplayText. You can call this method to change the SplashScreenForm‘s text.

    The code below demonstrates the MySplash class that implements the ISplash interface.

    using DevExpress.ExpressApp.Win;
    //...
    public class MySplash : ISplash {
        static private SplashScreenForm form;
        private static bool isStarted = false;
        public void Start() {
            isStarted = true;
            form = new SplashScreenForm();
            form.Show();
            System.Windows.Forms.Application.DoEvents();
        }
        public void Stop() {
            if(form != null) {
                form.Hide();
                form.Close();
                form = null;
            }
            isStarted = false;
        }
        public void SetDisplayText(string displayText) {
        }
        public bool IsStarted {
            get { return isStarted; }
        }
    }
    
  3. Access the WinApplication.cs (WinApplication.vb) file. Set the SplashScreen property to a new MySplash class instance.

    private void InitializeDefaults() {
       //...
       SplashScreen = new MySplash();
       // ...
    }
    
  4. You can display loading progress information. To do this, implement the the ISupportUpdateSplash interface in the MySplash class and add the UpdateInfo method to the SplashScreenForm class.

    public class MySplash : ISplash, ISupportUpdateSplash {
        // ...
        public void UpdateSplash(string caption, string description, params object[] additionalParams) {
            form.UpdateInfo(description);
        }
    }
    // ...
    public partial class SplashScreenForm : Form {
        // ...
        internal void UpdateInfo(string info) {
            label2.Text = info;
        }
    }
    
  5. Start the application to see the result.

    CustomSplashForm