Problem with splash screen - C # - VS2005

I have an application.

First I show a splash screen, a shape, and this splash will cause another shape.

Problem. When a splash shape is displayed, if I then open another application at the top of the splash and then minimize this newly opened application window, the splash screen turns white. How can I avoid this? I want my splash to display clearly and not be affected by any application.

+1
c # winforms splash-screen
Dec 25 '08 at 12:45
source share
3 answers

You need to display the splash screen in another thread - your new form loading code is currently blocking the splash screen UI thread.

Start a new thread, and in this thread create your splash screen and call Application.Run(splash) . This will launch a new message pump on this topic. You will then need to make your main UI thread back into the splash screen UI thread (for example, using Control.Invoke / BeginInvoke) when it is ready, so the splash screen may close itself.

It is important to make sure that you are not trying to change the user interface control from the wrong stream - use only the one on which the control was created.

+5
Dec 25 '08 at 13:21
source share

The .NET framework has excellent built-in screensaver support. Launch a new WF project, Project + Add Reference, select Microsoft.VisualBasic. Add a new form, name it frmSplash. Open Project.cs and do this:

 using System; using System.Windows.Forms; using Microsoft.VisualBasic.ApplicationServices; namespace WindowsFormsApplication1 { static class Program { [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); new MyApp().Run(args); } } class MyApp : WindowsFormsApplicationBase { protected override void OnCreateSplashScreen() { this.SplashScreen = new frmSplash(); } protected override void OnCreateMainForm() { // Do your time consuming stuff here... //... System.Threading.Thread.Sleep(3000); // Then create the main form, the splash screen will close automatically this.MainForm = new Form1(); } } } 
+3
Dec 26 '08 at 15:11
source share

I had a similar problem that you might want to check out. Stack overflow answer I worked great for me - you can take a look.

+1
Dec 26 '08 at 0:53
source share



All Articles