VB.NET - how to change the splash screen image dynamically?

Asked By Nani gd on 22-Mar-12 09:55 AM
Earn up to 10 extra points for answering this tough question.
HI Experts,
i have designed splash screen, i am using it for couple of application.
my requirement is , for differnt application, i want to change the background image.
How can i change the background image dynamically in VB.NET
 Help me.

[)ia6l0 iii replied to Nani gd on 22-Mar-12 12:51 PM
If it is a png or a gif, you can change the background using Microsoft picture editor or a freeware like Irfanview

However, you also seem to ask if it is possible to change in VB.Net , which contradicts to your first question. In such a case, use the Image.FromFile method of the PictureBox control. In the follx.owing line of code, MyPictBox is the picture bo


Hope this helps.
D Company replied to Nani gd on 22-Mar-12 01:14 PM
Its simple need not to do much things. in .net SplashScreen is a class, just change the image source at runtime. like this
SplashScreen splashScreen = new SplashScreen("here your new image");
splashScreen.Show(true);// to show this

Reena Jain replied to Nani gd on 23-Mar-12 07:59 AM

DynamicSplashScreen is reusable class which  can be used as base class for your custom splash screen. Check inline comments for details.

public class DynamicSplashScreen:Window
  public DynamicSplashScreen()
    //Defaults for splash screen
    this.ShowInTaskbar = false;
    this.WindowStartupLocation = WindowStartupLocation.Manual;
    this.ResizeMode = ResizeMode.NoResize;
    this.WindowStyle = WindowStyle.None;
    this.Topmost = true;
    this.Loaded += OnLoaded;
  private void OnLoaded(object sender, RoutedEventArgs e)
    //calculate it manually since CenterScreen substracts
    //taskbar's height from available area
    this.Left = (SystemParameters.PrimaryScreenWidth - this.Width) / 2;
    this.Top = (SystemParameters.PrimaryScreenHeight - this.Height) / 2;

refer this for more help
Nani gd replied to Reena Jain on 26-Mar-12 02:52 AM
i have tried all the ways.. nothing is working
some one should give soln for my problem.
help me.
Craig Nicholas replied to Nani gd on 18-Apr-12 06:33 AM
It took me a little while to work out why mine wasn't working. (I'm using VB 2008).

Presuming you've added a template splashscreen item and have selected it in the splash screen list in the Application properties plus you've added the MyApplication_Startup event handler in ApplicationEvents.vb (see http://msdn.microsoft.com/en-us/library/y4kc7w3s.aspx ) then you can add the required code e.g.

         Dim splash As SplashScreen = CType(My.Application.SplashScreen, SplashScreen)
         Dim img As New System.Drawing.Bitmap(My.Settings.SplashScreenImage)
         splash.MainLayoutPanel.BackgroundImage = img

The problem I had was I initially tried to assign img to splash.BackgroundImage which didn't work. Assigning it to MainLayoutPanel.BackgroundImage worked. 
Craig Nicholas replied to Craig Nicholas on 20-Apr-12 08:46 AM
Putting this code in MyApplication_Startup was not a good idea since it seems the SplashScreen is launched in its own thread so cross thread communication required to resize and reposition based on screen. I moved it into the splashscree code behind which achieved the desired affect.