Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
How can I show changing texts in splash screen e.g in professional splash screens .. things like loading components...coneecting to database etc show up... how can i do that? I am using visual basic...Thanks in advance
Posted 10-Nov-12 4:38am
Comments
OriginalGriff at 10-Nov-12 9:44am
   
How are you showing a splash screen?
Where are you doing the updates as you load?
shahharis at 10-Nov-12 9:46am
   
didnt kind of get u? :(
OriginalGriff at 10-Nov-12 9:58am
   
How are you showing the splash screen at present? If it is your own form then we can do it one way, if it is a control of some form then we may have to do it another.
How are you loading things at the moment? We need to know because it may be relevant to how you display things: a monolithic SQL SELECT into a DataGridView may need to be changed to provide progress info.
Remember, we can't see your screen, or access your HDD, or read your mind! :laugh:

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In the past I wrote a splash screen that used the override of OnPaint.
 
Its a little rusty, but does the job. I'm not used to vb... so excuse the look.
 
Make a splash form.
 
Get rid of the border, so set it to none.
Centre screen
I made mines size 485 x 300
 
Public Class Splash
 
    Public barwidth As Integer = 200
    Private Sub Splash_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim hfont As New Font("Arial", 12, FontStyle.Bold)
        Dim font As New Font("Arial", 10, FontStyle.Regular)
 
        e.Graphics.DrawString("Some Static Text", hfont, New SolidBrush(Color.Black), 33, 100)
        e.Graphics.DrawString("More Static Text", font, New SolidBrush(Color.Black), 33, 120)
 
        e.Graphics.DrawString("Loading..", font, New SolidBrush(Color.Gray), 33, 181)
 
        ShowProgress(0, "Loading..")
    End Sub
    Public Sub ShowProgress(ByVal percentage As Integer, ByVal operation As String)
        Dim font As New Font("Arial", 8, FontStyle.Regular)
        Dim gr As Graphics = CreateGraphics()
        gr.DrawRectangle(New Pen(Color.Black), New Rectangle(142, 202, barwidth, 19))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(255, 0, 0)), New Rectangle(143, 203, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(240, 0, 0)), New Rectangle(143, 204, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(230, 0, 0)), New Rectangle(143, 205, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(220, 0, 0)), New Rectangle(143, 206, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(210, 0, 0)), New Rectangle(143, 207, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(200, 0, 0)), New Rectangle(143, 208, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(195, 0, 0)), New Rectangle(143, 209, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(190, 0, 0)), New Rectangle(143, 210, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(185, 0, 0)), New Rectangle(143, 211, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(180, 0, 0)), New Rectangle(143, 212, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(175, 0, 0)), New Rectangle(143, 213, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(170, 0, 0)), New Rectangle(143, 214, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(165, 0, 0)), New Rectangle(143, 215, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(160, 0, 0)), New Rectangle(143, 216, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(155, 0, 0)), New Rectangle(143, 217, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(150, 0, 0)), New Rectangle(143, 218, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(145, 0, 0)), New Rectangle(143, 219, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(140, 0, 0)), New Rectangle(143, 220, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.FromArgb(135, 0, 0)), New Rectangle(143, 221, (barwidth * percentage) / 100, 1))
        gr.FillRectangle(New SolidBrush(Color.IndianRed), New Rectangle(0, 250, 485, 50))
        gr.DrawString(operation, font, New SolidBrush(Color.WhiteSmoke), 5, 250)
    End Sub
End Class
 

That is what is in the back of the splash screen.
 
Barsize is pretty much how many pixels wide you want the bar to be.
 
This is what I have in my main form.
 
Imports System.Threading
 
Public Class Form1
    Dim splashForm As Splash
    Public Sub New()
        Me.Enabled = False
        splashForm = New Splash()
        splashForm.Owner = Me
        splashForm.Show()
        Application.DoEvents()
 
        'simulate work!
        Thread.Sleep(1000)
        splashForm.ShowProgress(10, "Describe what you are loading here.....")
        Thread.Sleep(1000)
        splashForm.ShowProgress(25, "More description of loading here.....")
        Thread.Sleep(1000)
        splashForm.ShowProgress(70, "Bit more")
        Thread.Sleep(1000)
        splashForm.ShowProgress(100, "Finished!")
        Thread.Sleep(1000)
    End Sub
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Enabled = True
        Me.Visible = True
        splashForm.Close()
 
    End Sub
End Class
 

I used this in a compact framework environment because I wanted a gradient progress bar on the splash screen.
 
There are probably loads of much better ways of doing it, but this method does work.
 
Just takes a bit of tweaking of coordinates!
 
Good luck!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 562
1 Sergey Alexandrovich Kryukov 484
2 Maciej Los 325
3 DamithSL 233
4 Mathew Soji 195
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100