|
-
Oct 5th, 2000, 12:27 PM
#1
Thread Starter
Hyperactive Member
I want to wait until its finished and then display it. Is there a way of doing this?
I load bitmaps, change the colour of controls etc, and i can see it all happening. If i could `show` a form, but not actually see it, then, maybe at the end of form_load or form_activate, display it, i think that would do the trick.
Any ideas?
Alex.
-
Oct 5th, 2000, 12:43 PM
#2
Addicted Member
you can hide it when starting to load
Code:
Form_Load().......
Me.Hide
.
.
' Your Code here
.
.
.
Me.Show
End Sub
[Edited by ShIzO on 10-05-2000 at 01:46 PM]
-
Oct 5th, 2000, 12:45 PM
#3
Hyperactive Member
Couple questions .
Is it the main form ?
In what event do you load the bitmaps and change the coloures ?
[]Private[]
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Oct 5th, 2000, 01:36 PM
#4
You can also add a DoEvents which will process all the code before it and then after it's done, it continues to the next processes.
-
Oct 5th, 2000, 01:43 PM
#5
Hyperactive Member
Trickery is best
1) Do not have your main for and the startup form.
2) Use a sub main or another form as startup form and use this code to Load your main form (not show)
3) When the main form is ready (you can set a flag for that or do it any number of ways), user mainForm.Show
You will still see some redraw (depending on your machine I guess) but not as much as you would otherwise see.
Other techniques include placing a picturebox over the entire form and only taking it away once the form has finished all the stuff you mentioned... Sort of like hiding the ugly redraw behind a curtain...
I always use the Loading Form as above though... Sometimes it's called a Splash Screen 
Cheers
-
Oct 5th, 2000, 02:19 PM
#6
Code:
Sub Main
Form1.Hide
Load Form1
Form1.Show
End Sub
-
Oct 6th, 2000, 09:05 AM
#7
Thread Starter
Hyperactive Member
All the forms (except the initial one) are shown modally. If you hide them, they go away and execution continues on the next line.
I cant see a way of not-calling them modally - the calling form needs to wait for them to terminate to continue. I guess i could make them non-modal and have the calling form loop waiting for the called form to signal its termination, but thats tacky and i`m sure would impact performance.
There must be a way to say `display this form only when the end of form_load is reached`, surely?
In this instance the form thats being drawn in bound to a database, controls are created dynamically etc - theres a lot going on, and you often have up to 2 seconds before everything is sorted out!
Thanks,
Alex.
-
Oct 6th, 2000, 09:23 AM
#8
If the forms are shown modally, you can use the LockWindowUpdate API for your purpose. Put it in the load event of the modal form.
Code:
Option Explicit
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Sub Form_Load()
Dim retVal As Long
retVal = LockWindowUpdate(Me.hWnd)
' do you're loading stuff here
retVal = LockWindowUpdate(0)
End Sub
-
Oct 6th, 2000, 09:28 AM
#9
transcendental analytic
Maybe it got a bit unclear so...
Code:
Load Form1 'loads your form, not displaying it
Form1.Show 'loads if not loaded and sets the visible property to true
Form1.Hide 'loads if not loaded and sets the invisible property to false
Actually what you do is call Load Form1, immediately before you start loading other stuff.
Also make sure you don't have any form1.show or form1.visible=true before all stuff have been loaded onto the form.
If it's still bugging you, you can put a breakpoint on the Load statement and follow the process by pressing F8 and watch which statement makes form1 visible.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 6th, 2000, 12:02 PM
#10
Thread Starter
Hyperactive Member
I tried the LockWindowUpdate call - no difference!
Strange!
Thanks,
Alex.
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
|