locked
How to show Splash Screen while loading another form RRS feed

  • Question

  • Hi everybody,

    I'm trying to create a splash screen with a form, picturebox which is being populated from my.resources .

    At every time I open the software, It will pick a random .gif called "load + x" 

    My problem is that I want to prevent a freeze  .gif  animation. 

    I'm trying to use a Async task with a Task.Delay in Task.Run, like suggested from a Moderator:

    Gith Rep

    But unfortunately I can't see any changin  and the .gif is not fully animated.

     I did read on  Same problem topic but I got problems on knowing where should I use this

    PictureBox1.Image = DirectCast(My.Resources.ResourceManager.GetObject("load" & r.Next(1, 12)), Image)

    Can someone help me? Thanks

    Saturday, September 26, 2020 2:00 PM

Answers

  • Hi

    EDIT: You have asked a question so you need to change the type back from DISCUSSION to QUESTION>

    You should post your code. Otherwise we have nothing to work with.

    Here is a working example.

    I created a new project.  I added a Form2 to the project.  I added a GIF (called _1) to the project resources.  I added a PictureBox1 to Form2.  I set the Solution Explorer->My Project->Application-Splash Screen  to Form2. I added the following code to Form2

    Option Strict On
    Option Explicit On
    Public Class Form2
    	Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    		PictureBox1.Image = My.Resources._1
    	End Sub
    End Class

    When run, I get the Splash Screen with a smoothly running GIF followed by Form1 after the timeout.


    Regards Les, Livingston, Scotland



    • Edited by leshay Saturday, September 26, 2020 4:03 PM
    • Marked as answer by Mattia Fanti Tuesday, September 29, 2020 12:28 AM
    Saturday, September 26, 2020 3:53 PM

All replies

  • I could not read your comment with code over on StackOverflow. What I will say is I would not provide a recommendation that I would not use myself.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Saturday, September 26, 2020 3:33 PM
  • Hi

    EDIT: You have asked a question so you need to change the type back from DISCUSSION to QUESTION>

    You should post your code. Otherwise we have nothing to work with.

    Here is a working example.

    I created a new project.  I added a Form2 to the project.  I added a GIF (called _1) to the project resources.  I added a PictureBox1 to Form2.  I set the Solution Explorer->My Project->Application-Splash Screen  to Form2. I added the following code to Form2

    Option Strict On
    Option Explicit On
    Public Class Form2
    	Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    		PictureBox1.Image = My.Resources._1
    	End Sub
    End Class

    When run, I get the Splash Screen with a smoothly running GIF followed by Form1 after the timeout.


    Regards Les, Livingston, Scotland



    • Edited by leshay Saturday, September 26, 2020 4:03 PM
    • Marked as answer by Mattia Fanti Tuesday, September 29, 2020 12:28 AM
    Saturday, September 26, 2020 3:53 PM
  • Hi leshay,

    It  seemed too easy, but it seems splashscreen is dealing with async itself, so I simply did what you suggest and now the gif is animated fully despite any other code in the load of form2.

    Thanks!

    Tuesday, September 29, 2020 12:29 AM