Re: [RESOLVED] Splash Screen
How about make a textbox and add the following code to your Timer Event
VB Code:
lblPercent.caption = int(ProgressBar1.Max / ProgressBar1.Value) & "%"
Re: [RESOLVED] Splash Screen
Backwards, though;
VB Code:
lblPercent.caption = int( ProgressBar1.Value / ProgressBar1.Max ) & "%"
Re: [RESOLVED] Splash Screen
Quote:
Originally Posted by dglienna
Backwards, though;
VB Code:
lblPercent.caption = int( ProgressBar1.Value / ProgressBar1.Max ) & "%"
Its not quite working the way it is supposed to. This is what I have so far. When the progress bar reaches 100% then the splash screen hides and the other form shows
VB Code:
Private Sub DrawProgress(ByVal Value As Long, ByVal Max As Long)
Dim strPercent As String
Dim intPercent As Integer
Dim intWidth As Integer
Dim intHeight As Integer
intPercent = (Value / Max) * 100
strPercent = intPercent & "% Complete"
intWidth = Picture1.TextWidth(strPercent)
intHeight = Picture1.TextHeight(strPercent)
With Picture1
.FillStyle = vbFSSolid
.BackColor = vbWhite
.ForeColor = vbBlue
.DrawMode = vbCopyPen
.CurrentX = (Picture1.ScaleWidth - intWidth) / 2
.CurrentY = (Picture1.ScaleHeight - intHeight) / 2
Picture1.Print strPercent
.DrawMode = vbNotXorPen
End With
If intPercent > 0 Then
Picture1.Line (-50, -50)-(Picture1.Width * intPercent / 100, Picture1.Height), vbBlue, BF
Else
Picture1.Line (-50, -50)-(Picture1.Width, Picture1.Height), vbWhite, BF
End If
Picture1.Refresh
If intPercent = 100 Then
'hide the splash screen
frmSplash.Hide
'show my form
frmTranslator.Show
End If
End Sub
1 Attachment(s)
Re: [ALMOST-RESOLVED] Splash Screen
Quote:
Its not quite working the way it is supposed to. This is what I have so far. When the progress bar reaches 100% then the splash screen hides and the other form shows
1) What is the problem? Isn't that the way it's supposed to work? When the pb gets to 100% it closes and the form opens?
2) You aren't using a Progress Bar? Look at this example to see what I mean.
It's simple, and uses a loop for movement, but it uses the progress bar control.
Re: [ALMOST-RESOLVED] Splash Screen
Quote:
Originally Posted by dglienna
1) What is the problem? Isn't that the way it's supposed to work? When the pb gets to 100% it closes and the form opens?
2) You aren't using a Progress Bar? Look at this example to see what I mean.
It's simple, and uses a loop for movement, but it uses the progress bar control.
The progress bar is a picture box to look like a progress bar that has 0% to 100% as the progress bar increases.
When the bar gets to 100%, the splash hides and the main form shows, but when you click off the main form, a few seconds later, the main form comes back and then a domino effect. The only way to completely close down the app is to do alt+ctrl+del
Re: [ALMOST-RESOLVED] Splash Screen
In the lost focus event, put a timer.enabled = false, and a unload form.
Re: [ALMOST-RESOLVED] Splash Screen
In that case, use
VB Code:
Unload frmSplash
'instead of
'frmSplash.Hide
Also, if you are using a picturebox as a progressbar, use something like:
VB Code:
picProgress.CurrentX = (picProgress.ScaleWidth / 2) - (picProgress.TextWidth("X") / 2)
picProgress.CurrentY = (picProgress.ScaleHeight / 2) - (picProgress.TextHeight("X") / 2)
picProgress.Print "x%"
Phreak
Re: [ALMOST-RESOLVED] Splash Screen
Quote:
Originally Posted by dglienna
In the lost focus event, put a timer.enabled = false, and a unload form.
any lostfocus even just allows the progress bar to refresh and the splash screen stays on screen.
Re: [ALMOST-RESOLVED] Splash Screen
This'll do it:
VB Code:
If ProgressBar1.Value = ProgressBar1.Max Then
Timer1.Enabled = False
frmTranslator.Show
Unload frmSplash
'frmSplash.Hide
End If
Phreak
Re: [ALMOST-RESOLVED] Splash Screen
Yes. If you hide the form, it will come back with the MAX reached with the bar, and get stuck. You need to unload the form.
Re: [ALMOST-RESOLVED] Splash Screen
Quote:
Originally Posted by «°°phReAk°°»
This'll do it:
VB Code:
If ProgressBar1.Value = ProgressBar1.Max Then
Timer1.Enabled = False
frmTranslator.Show
Unload frmSplash
'frmSplash.Hide
End If
Phreak
I was thinking about that before I came back and I did something similar which also worked. Nothing has come back on screen after clicking off the main form.
I did:
VB Code:
If intPercent > 0 Then
Picture1.Line (-50, -50)-(Picture1.Width * intPercent / 100, Picture1.Height), &H4000&, BF
Else
Picture1.Line (-50, -50)-(Picture1.Width, Picture1.Height), vbWhite, BF
End If
Picture1.Refresh
'if the progress bar reaches 100% then
If intPercent = 100 Then
'disable the timer
Timer1.Enabled = False
'hide the splash screen
frmSplash.Hide
'show the main screen
frmTranslator.Show
End If
End Sub
Re: [ALMOST-RESOLVED] Splash Screen
Quote:
Originally Posted by «°°phReAk°°»
This'll do it:
VB Code:
If ProgressBar1.Value = ProgressBar1.Max Then
Timer1.Enabled = False
frmTranslator.Show
Unload frmSplash
'frmSplash.Hide
End If
Phreak
No progress bar, though...
VB Code:
If Value = Max Then
Timer1.Enabled = False
frmTranslator.Show
Unload frmSplash
'frmSplash.Hide
End If
Re: [ALMOST-RESOLVED] Splash Screen
Although, instead of using frmSplash.Hide, you should still unload it, as it will cause errors later if you aren't using it again. Or, if you don't want to do that, use something like this in the "Exit" part of your code:
VB Code:
Dim j As Form
For Each j In Forms
Unload j
Next
..to unload all the forms.
Phreak
Re: [ALMOST-RESOLVED] Splash Screen
Quote:
Originally Posted by «°°phReAk°°»
Although, instead of using frmSplash.Hide, you should still unload it, as it will cause errors later if you aren't using it again. Or, if you don't want to do that, use something like this in the "Exit" part of your code:
VB Code:
Dim j As Form
For Each j In Forms
Unload j
Next
..to unload all the forms.
Phreak
definately a valid point you have there. i didnt think about that. must be the newb coming out in me.
i am going to have to research how to unload the form because i only know how to do it when you click on something.... time to search the braille book on this one haha
found it
Re: [RESOLVED] Splash Screen
I havn't read all the post and this might have been stated, but you could just as easily just add a loading command (step subroutine) for whatever it is that takes ur form so long to load
For instance, I have variety of apps that build database (or retrieve info rather) upon load so that user interaction during prog is not slowed by streaming feeds, I simply load in at start and load out at close (datagrids filled and things) anyway, point is, i add a "splashscreen" which generally just has a progress bar and the word loading or somthing to that effect.
Then on my main form, whever ever the largest chunck of work is being done on load (ie the For Each in database statements), I add one simple line just before "Next" - stepProBar()
the code for it is simple tho you'll need to delagate it on splash form since it's on seperate thread.
To make this easier, add ur splash screen, add a probar to the splash screen
in splash screen code put :
proBar Code:
Delegate Sub stepBarI(ByVal i As Integer)
Public Sub stepI(ByVal i As Integer)
If Me.ProgressBar1.InvokeRequired = True Then
Dim d As New stepBarI(AddressOf stepI)
Invoke(d, New Object() {i})
Else
Me.ProgressBar1.Value += i
End If
End Sub
Public Sub stepBar()
If Me.Visible = True Then
If Me.ProgressBar1.Value < Me.ProgressBar1.Maximum Then
stepI(1)
Else
stepI(0)
End If
End If
End Sub
then ofcourse on your main form, wherever the main work is going on put "stepBar" for each loading command, example:
mainForm Code:
Public Sub prepDatabase()
For Each item In yourDatabase
ArrayList.Add(item)
stepbar() <---Here it will step 1 interval after every added item
Next
End Sub 'this is a really bad example but u should get the idea
this is not likly the best way, but it's what has worked great for me so far, so i figured i'd add, timers can be messy and seem to cause more overhead, this method is very light on my cpu
enjoy
Re: [RESOLVED] Splash Screen
This thread is ancient history.