Solved

Disabling the main form during startup of a VB 6 app

Posted on 2007-03-23
8
212 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 49

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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now