Results 1 to 10 of 10

Thread: Dont want to watch my form being drawn!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    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.

  2. #2
    Addicted Member ShIzO's Avatar
    Join Date
    Apr 1999
    Location
    Bartlett, IL
    Posts
    189
    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]
    www.HardFind.com -buy/sell/trade your used hardware.

  3. #3
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    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 !!!!!

  4. #4
    Guest
    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.

  5. #5
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    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
    Paul Lewis

  6. #6
    Guest
    Code:
    Sub Main
        
        Form1.Hide
        Load Form1
        Form1.Show
    
    End Sub

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    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.

  8. #8
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    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

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    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.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    London
    Posts
    290
    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
  •  



Click Here to Expand Forum to Full Width