If you're looking for the easiest way, you can use the excellent native .NET Framework support for splash screens. You need to discard any irrational fears that may arise including something called βVisual Basicβ in a C # application, but this way saves you the trouble of minimizing your own custom solution and worrying about things like multithreading, calling, and all that. In any case, it all comes down to the same IL. Here's how it works:
Add a link to Microsoft.VisualBasic in your project.
Add a new form (named as SplashForm ) as your splash screen.
To make it look like a proper splash screen, set the FormBorderStyle property to "None" and its StartPosition property to "CenterScreen". You can add any controls or images to this form that you want to display on the splash screen in this form.
Add the following code to your Project.cs file:
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 SplashScreenApp().Run(args); } } public class SplashScreenApp : WindowsFormsApplicationBase { protected override void OnCreateSplashScreen() { this.SplashScreen = new SplashForm(); this.SplashScreen.ShowInTaskbar = false; this.SplashScreen.Cursor = Cursors.AppStarting; } protected override void OnCreateMainForm() {
If you want to do something like creating a transparent splash screen in the style of Adobe Photoshop, you can add an PNG image of an alpha channel to your project resources file, and then add the following code to your splash screen form, replacing splashImage with the path to your embedded image resource:
protected override void OnPaintBackground(PaintEventArgs pevent) { Graphics g = pevent.Graphics; g.DrawImage(splashImage, new Rectangle(0, 0, this.Width, this.Height)); } protected override void OnPaint(PaintEventArgs e) {
For this to work, make sure you turn off double buffering, otherwise you will get a black background in your form. There really is no reason to double the splash screen buffer anyway.
Cody Gray Dec 06 2018-10-12T00: 00Z
source share