by Matthew Roberts (26 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
Simple API call that tells whether or not a particular form is open. Useful for managing popup forms or a series of forms.
Sample usage:
If FormIsOpen("Color Picker") Then
' ....Do Something Here
Else
' ...Do Something Else Here...
End If
Inputs
FormName
Assumes
Goes by form title, so multiple instances of a form can be used as long as their titles are different. Also works with other applications...any window in fact, so it is not limited to your VB forms.
Code Returns
Boolean. True=Form is open.
API DeclarationsPrivate Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Public Function FormIsOpen(FormCaption) As Boolean
FormIsOpen = FindWindow(vbNullString, FormCaption)
End Function