dim obj as form for each obj on forms ... if obj.name=要检测的窗体.name then msgbox "窗体已经showed" ... next set obj=nothing
private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Function IsShow(FormName As String) As Boolean Dim lR As Long lR = FindWindow(vbNullString, FormName) If lR <> 0 Then IsShow = True Else IsShow = False End If End Function Private Sub Command1_Click() if IsShow("C窗体的标题")=False then c.show else msgbox "c窗体已经打开" end if End Sub
for each obj on forms
...
if obj.name=要检测的窗体.name then msgbox "窗体已经showed"
...
next
set obj=nothing
Public Function IsShow(FormName As String) As Boolean
Dim lR As Long
lR = FindWindow(vbNullString, FormName)
If lR <> 0 Then
IsShow = True
Else
IsShow = False
End If
End Function
Private Sub Command1_Click()
if IsShow("C窗体的标题")=False then
c.show
else
msgbox "c窗体已经打开"
end if
End Sub