Results 1 to 8 of 8

Thread: Make a form invisible?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Boston, MA
    Posts
    52

    Unhappy

    According to Mastering VB 6 by Evangelous Petrousos:

    "...the Load statement doesn't show the Form. You have to call the Form's Show method to display it..." (p.181)

    Now when I execute this code:

    Code:
    Private Sub Command1_Click()
    
    Dim Form as New frmMyForm
    Load Form
    
    End Sub
    the form is displayed, EVEN when I have frmMyForm.Visible = False!!! I don't understand! Is there something I have set, or something else I can look at? I've also tried this code:

    Code:
    Private Sub Command1_Click()
    
    Load frmMyForm
    frmMyForm.Visible = False
    
    End Sub
    Now, what happens is I see frmMyForm flash for a second. I don't want that! I just want to load it in the background!!I thought that you had to Show a form to make it show!!! Please help!!!

  2. #2

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Boston, MA
    Posts
    52

    ooops!

    I realized that this may be important. frmMyForm is a form in an MDI form. Does that matter? I don't know. I'll try it!

  3. #3
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245

    Here is a project I had in the past which I made use of the "Visible" property...

    Here is some source from a project I designed in the past...
    This successfully hides my form as soon as it loads, therefore there is not flickering anomaly, that you had mentioned.

    Code:
    Private Sub Form_Load()
    Dim address As String
    
        'Begin security coding
        Call RemoveProgramFromList
        frmBrowser.Visible = False
        
        'Start the watch for HideME HotKey presses
        tmrVisibleF.Enabled = True
        
        'Begin Navigate
        Open "file.dat" For Input As #1
            Input #1, address
        Close
            brwWebBrowser.Navigate address
    
    'Get the current size of the HTML Chat file
    Open address For Binary As #1
        lblLOF.Caption = LOF(1)
    Close
    
        'Load Icon Simulator
        frmMain.Show
    End Sub
    As you can see, I used the 'Visible" property in the Form's Load(). Mayhaps that is what you need to do aswell.

    Hope this helped...
    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Smile It's the MDI thang

    When you load a form as a child of an MDI form, it becomes visible. I would love to hear if someone knows how to get around this...
    ~seaweed

  5. #5
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Worldwide in the Sun
    Posts
    566
    If you only do a Load Form the form will be
    loaded into memory.

    It should come up after you do : Form.Show.

    Hiding a form can be done with the HIDE method.

    Form.Hide



    Cheers
    Ray

    Ray

  6. #6
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Before loading the form and hiding it you could turn off screen painting. Remember to turn it on though!

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  7. #7

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Boston, MA
    Posts
    52

    I'll try this stuff...

    Thanks for all your help! I think seaweed is right. I've tried setting the form with MDIChild set to false, and it loads only when I use the .show method and resizes without the flicker. I'll try the screen painting approach as well as the RemoveProgramFromList and see if those work, but does anyone know why an MDI child has to be visible and why VB overrides your settings for size and position? Thanks!

  8. #8

    Thread Starter
    Member
    Join Date
    May 2000
    Location
    Boston, MA
    Posts
    52

    Talking YEAH!!!!

    I figured this out, and it seems so obvious now!

    In an MDI environment, when you load an MDI child, it is automatically visible, so something like this will cause the flicker:
    Code:
    Private Sub LoadForm()
    
    Load frmChildForm
    frmChildForm.Height = 1000
    frmChildForm.Width = 2000
    
    End Sub
    But if you put the resize code in the form's load event, it will have done everything before it is visible, much like Daniel_Christie said. Example:

    frmMDI Code:
    Code:
    Private Sub LoadForm()
    
    frmMDIChild.Show
    
    End Sub
    frmMDIChild Code:
    Code:
    Private Sub Form_Load()
    
    Me.Height = 1000
    Me.Width = 2000
    'Anything else (i.e. Data Loading etc.)
    
    End Sub
    Just postin for all those who might have or have had a similar problem. Thanks everyone for your help!


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