|
-
March 25th, 1999, 06:45 AM
#1
hide and show FORMS without time delay
I created a MIDI-Form with a child forms.
When I click the command button (command1) on the currently shown Child form, in the background there are some calculations which take about 6 seconds. During this periode I want to hide the Child form and show an Form that indicates " Calculation please wait" So I placed the commands as followed:
Sub command1_click()
Form1.hide
Form2.shown (Form with label "Calculation please wait"
Different Iterations
......
Form2.hide
Form1.show
end sub
But instead of hiding the Form1 it is still visible
And of Form2 only the frame is visible.
What do I have to do to get the required result ????
Instead of hiding the FORM1 it would also be o.k. if the Form2 is visible on the top of Form1. Do you have any idea how to arrange the sequence of the forms
(bring to front, bring to back?????)
Thanks Peter
-
March 25th, 1999, 07:35 AM
#2
Re: hide and show FORMS without time delay
Hi,
There are lot of ways to do this. Basically what is happening is this:
VB can paint forms/controls etc only when *it* gets the chance to do it!.
In your click event, you are saying - Form2.show , but by the time the form is shown the long loop of processing ( ~6sec) has already started, and the processor is busy doing it.
Simplest solution would be to give back the control to VB , and then start processing.
Put a couple of 'DoEvents' and if it still doesn't work, put a .Refresh command
i.e
Form1.hide
DoEvents
DoEvents
Form2.show
Form2.Refresh
DoEvents
.. and then the processing logic. It should do the trick
Or have a timer and do your calcs on the timer event. Set timers interval small enough not to be noticeble.
Form1.hide
Form2.show
Form2.ZOrder VbBringtofront '' if you want to to be visible for sure!
' put a timer in Form1, set the Enabled to False
timer1.interval = 100 ' - 100ms
timer1.enabled = true
' By the time timer starts VB gets good chance to do house keeping!
In form 1's timer1_event do the calcs. and after finishing unload Form2
private sub timer1_timer()
' do calcs. On end
unload form2
timer1.enabled = false '' IMP line, otherwise it will run multiple times!
end sub
Note : For this kind of processing the programing style has to change a little :
in the sense that you dont know when the cals are over etc.
Ravi
-
March 25th, 1999, 08:55 AM
#3
Re: hide and show FORMS without time delay
thanks Ravi for your explanations. I sounds verry good I will try it in the afternoon
-
March 26th, 1999, 05:23 AM
#4
Re: hide and show FORMS without time delay
It works exactly how you explained
thanks a lot Peter !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|