Solved

Disabling the main form during startup of a VB 6 app

Posted on 2007-03-23
8
201 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

20 Experts available now in Live!

Get 1:1 Help Now