Results 1 to 9 of 9

Thread: Is form showing....?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    I have an MDI form, with a few child forms. How can I tell if a specific form is showing (not loaded!). I'm not having much luck. I mean, after the Show method has been used on the form, the function returns True, after the Unload or Hide method has been used on a form, it returns False.

    Thanks!

    ------------------
    - Chris
    [email protected]
    Q. Why do mice have small balls?
    A. Not that many know how to dance

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    is the .Visible property of the form not working?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    No, i made a function, this infact.

    Public Function IsOpen(ByVal strFormName As String) As Boolean
    ' Returns True if the specified form is open
    Dim i

    For i = 0 To Forms.Count - 1
    If Forms(i).Caption <> "MDI Form" Then
    If Forms(i).Name = strFormName Then
    If Forms(i).Visible = True Then
    IsOpen = True
    Exit Function
    End If
    End If
    End If
    Next i

    ' If gets to here, form is not open
    IsOpen = False

    End Function

    Trouble is, it don't work! Any clues anyone? Thanks,

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    This will return True if a given form is loaded and visible, otherwise it returns False.
    Code:
    Function isFormVisible(frmToCheck As String) As Boolean
    
        Dim frm As Form
    
        For Each frm In Forms
            If frm.Name = frmToCheck Then
                If frm.Visible Then
                    isFormVisible = True
                    Exit Function
                End If
            Else
                isFormVisible = False
            End If
        Next
        
    End Function
    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Thanks Marty!

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    You're welcome. I just looked again at the code and I suggest you make two small changes. 1) Change Exit Function to Exit For (just in case some day you want to add more code following the For/Next loop), and 2) Add another Exit For line following isFormVisible = False.

    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Will do, cheers!

  8. #8
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Chris, I don't think you can get the form showing and not loaded. As soon as you show your form. it fires the Form_Load event.

    ------------------

    Serge

    Senior Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Serge, but is it possible to determin if the form is loaded and showing, not just loaded?

    Sorry, perhaps I didn't make myself clear.

    Thanks for trying to help anyways!

    ------------------
    - Chris
    [email protected]
    Q. Why do mice have small balls?
    A. Not that many know how to dance

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