Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

splash from w/ progress bar

Posted on 2006-05-11
3
Medium Priority
?
262 Views
Last Modified: 2008-03-06
I want my applications to start in a sub main, to invoke the frmMain load event, and while this event is running to pop up a splash screen with a progress bar.  The screens are already designed, but I can't seem to get the splash screen to do anything.  As a test, I've done this, using the "sleep" to emulate having the load event do a lot of stuff:

Module modMain
    Sub main()
        Dim fMain As New frmMain

        Try
            If Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName).Length > 1 Then
                MsgBox("Application is already running on this machine!", _
                    MsgBoxStyle.Exclamation + MsgBoxStyle.OKOnly, "Shutting Down")
            Else
                fMain.ShowDialog()
            End If

        Catch ex As Exception
            MsgBox(Err.Description & " Startup")
        End Try
    End Sub
End Module

''''''''''''''''''''in frmMain
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim fSplash As New frmSplash

        fSplash.Show()

        System.Threading.Thread.Sleep(60000)
   end sub

'''''''''''''''''in frmSplash
    Private Sub timSplash_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timSplash.Tick
        Try
            If pbSplash.Value < 100 Then
                pbSplash.Value += 10
            Else
                pbSplash.Value = 10
            End If

        Catch ex As Exception

        End Try
    End Sub

    Private Sub frmSplash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Refresh()
        timSplash.Start()
    End Sub



The result is that frmSplash pops up, but not completely "painted" (e.g., the label caption doesn't show), and the progress bar does nothing.


what am I doing wrong?

Thanks.

0
Comment
Question by:g_johnson
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 16661250
"what am I doing wrong?"

This line:

    System.Threading.Thread.Sleep(60000)

Completely suspends your application for sixty seconds...thus preventing it from painting itself properly or responding to your Timer events.

0
 
LVL 4

Author Comment

by:g_johnson
ID: 16661290
thanks -- so it turns out to be a bad test.

I put in a better test

for l = 1 to 10000000000
       application.doevents
next 'l

And all works fine ...

thanks again.

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16661320
Also, instead of:

    fMain.ShowDialog()

It should be:

    Application.Run(fMain)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question