CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: is form loaded

  1. #1
    Join Date
    Feb 2000
    Posts
    440

    is form loaded

    Hi,

    In certain point in my program I want to check if a form is loaded. I tried to do this by checking the "form.visible" property. However when I check this property if the form is not loaded it starts to load itself which is undesirable. Can anyone suggest better approach.

    Thanks

    Valery Iskarov Nikolov
    http://listen.to/quark

  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: is form loaded


    private Function IsFormLoaded(byval FormName as string) as Boolean

    Dim fTmp as Form

    for Each fTmp In Forms
    If fTmp.Name = FormName then
    IsFormLoaded = true
    Exit for
    End If
    next fTmpo
    End Function




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Feb 2000
    Posts
    440

    Re: is form loaded

    10x, That's it
    Regards

    Valery Iskarov Nikolov
    http://listen.to/quark

  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: is form loaded

    You can use the forms collection

    public Function IsFormLoaded(strName as string) as Boolean

    Dim frm as Form

    IsFormLoaded = false
    for Each frm In Forms
    If frm.Name = strName then
    IsFormLoaded = true
    Exit for
    End If
    next frm

    End Function




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  5. #5
    Join Date
    Nov 2001
    Posts
    4

    Re: is form loaded

    I would add a property to the form I want to check or loading.


    option Explicit
    private m_FormLoaded as Boolean
    private Sub Form_Load()
    m_FormLoaded = true
    ' do other stuff
    End Sub

    public property get isLoaded() as Boolean
    isLoaded = m_FormLoaded
    End property

    public property let isLoaded(newVal as Boolean)
    m_FormLoaded = newVal
    End property







  6. #6
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: is form loaded

    One thing you need to keep in mind is when accessing a property of a form, the form actually get's loaded, so after a loop checking for the property, all forms will be loaded.

    Tom Cannaerts
    [email protected]
    Moderator on http://www.vbcodelibrary.co.uk/board

    A bottomless pit, I'm sure it came with the place, who would dig one on purpose?
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

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

Featured