Is a certain form open?
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
Original Author: Matt Roberts
Inputs
FormName
Assumptions
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.
Returns
Boolean. True=Form is open.
API Declarations
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Code
Public Function FormIsOpen(FormCaption) As Boolean
FormIsOpen = FindWindow(vbNullString, FormCaption)
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.