Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Start Up Picture

How can we show startup picture when my application starts as every software hows like Photoshop ,vs word etc?? I planed to paste it on form and then show it but there is top blue bar coming that has controls etc any idea/

like image 329
Afnan Bashir Avatar asked Dec 06 '10 09:12

Afnan Bashir


People also ask

Where is today's Microsoft picture from?

The current spotlight image can be found at C:\ProgramData\Microsoft\Windows\SystemData\<User's SID>\ReadOnly\LockScreen_O, while the current and all previous images can be found in %localappdata%\Packages\Microsoft. Windows.

How do I change the startup picture in Windows 10?

Press the Windows key to launch the Start Screen. Click on the User Tile on top right corner of the Start screen. Select Change Account Picture. Click one of the provided background images or use the Browse button and select any image from your computer, Bing, SkyDrive, or even your camera.


1 Answers

If you're looking for the simplest way, you can use the .NET Framework's excellent built-in support for splash screens. You'll have to put aside any irrational fears that you might have of including something with the name "Visual Basic" in a C# application, but this way will save you from having to roll your own custom solution and worry about things like multi-threading, invoking, and all that. It all compiles down to the same IL in the end anyway. Here's how it works:

  1. Add a reference to Microsoft.VisualBasic to your project.

  2. Add a new form (named something like SplashForm) to serve as your splash screen.

  3. To make it look more like a proper splash screen, set the form's FormBorderStyle property to "None" and its StartPosition property to "CenterScreen". You can add any controls or images to this form that you want to be displayed on the splash screen to this form.

  4. 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()
             {
                 //Perform any tasks you want before your application starts
    
                 //FOR TESTING PURPOSES ONLY (remove once you've added your code)
                 System.Threading.Thread.Sleep(2000);
    
                //Set the main form to a new instance of your form
                //(this will automatically close the splash screen)
                this.MainForm = new Form1();
              }
           }
        }
    

If you want to do something fancy like create a transparent splash screen in the style of Adobe Photoshop, you can add an alpha-channel PNG image to your project's 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)
{
    //Do nothing here
}

For this to work, make sure that you have double buffering turned off, or else you'll get a black background to your form. There's really no reason to double buffer a splash screen anyway.

like image 196
Cody Gray Avatar answered Oct 19 '22 09:10

Cody Gray