Solved

Disabling the main form during startup of a VB 6 app

Posted on 2007-03-23
8
228 Views
Last Modified: 2012-05-05
My VB6 app runs a splash screen that calls the main form. The main form involves a lot of processing before it's ready for user interaction.

I'm trying to set the main form to enabled = false for about 8 seconds to cover the processing period. This is easily done once the form is fully visible and its processing is done. But that doesn't meet the need to prevent premature user interaction during the initial processing, and I can't find a workaround either for the splash screen or during the main form loading period.

Suggestions for solutions gratefully received.

0
Comment
Question by:Gordon_Atherley
8 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 18783906
How are you opening your 'Main Form' - please show the code that creates and opens the form object.

AW
0
 

Author Comment

by:Gordon_Atherley
ID: 18783926
In the splash form

Private Sub Timer1_Timer()
    frmDataFromClass.Show 'This is the main form
    Unload Me
 End Sub
0
 
LVL 50

Assisted Solution

by:Ryan Chong
Ryan Chong earned 166 total points
ID: 18784307
You can also put your processing scripts in your splash screen form if necessary, so that you no need to load your processing scripts again on your main form. Make sense?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 12

Assisted Solution

by:jkaios
jkaios earned 166 total points
ID: 18784328
Instead of using a Timer on the splash form, you can do this approach.

1. Add a standard module (if not already added)
2. Create a procedure call "Sub Main"
3. Set the Startup Object via the Project->Properties dialog to 'Sub Main'
4. In the Sub Main procedure, use the following code:

Private Sub Main()

   '// Show the splash screen
   frmSplash.Show
   frmSplash.Label1.Caption = "Loading main program, please wait ..."
   DoEvents

   '// Load the main form to execute the processing, but do not display it yet
   Load frmMain
   
   '// At this moment, the codes in the Form_Load event of the main form finished running
   '   so, we unload the Splash screen.
   Unload frmSplash

   '// Now display the main application form
   frmMain.Show

End Sub
0
 
LVL 12

Expert Comment

by:jkaios
ID: 18784333
>> 2. Create a procedure called "Sub Main" IN THE STANDARD MODULE (added in step 1)
0
 

Author Comment

by:Gordon_Atherley
ID: 18784887
Thanks for these leads. I'll test them out and report back.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 168 total points
ID: 18784930
to "disable" a form when loading, use the form_load event of the form itself:

Private Sub Form_Load()
  'show and disable the form
  me.Enabled = false
  me.Visible = true
  Doevents

  ' here, do the other processing
  ...

End Sub
0
 

Author Comment

by:Gordon_Atherley
ID: 18785721
Thanks to you all., I arrived at a workaround.

I found that the solutions you offered caused problems with form resizing and other background processes such as loading listviews. Then the solutionhit me: ensure that the loading of lthe lists and menubar leaves them disabled.

The lists and menubar are enabled after a wait of a few seconds following the execution of the processes. Not glamourous but effective.

You all led me to try things out, which brought me to my solution,  so I'll divide the points. Many thanks.

Gordon

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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