Visual Basic 6 表单

3
我怎样才能知道除了我正在工作的表单之外的表单是打开还是关闭的?
3个回答

7
你需要区分“已加载”和“可见”。
  • For visiblility just check the Visible property (noting that doing so for an unloaded form will cause it to become loaded).
  • For the loading state unfortunately there is no property. You have to iterate over all forms, and look whether your form is contained in the list of loaded forms:

    Public Function IsFormLoaded(FormToCheck As Form) As Boolean
      Dim F As Form 
      For Each F In Forms
        If F Is FormToCheck Then
          IsFormLoaded = True
          Exit Sub
        End If
      Next
    End Sub
    

全局集合Forms包含当前加载的所有窗体。


3

您可以搜索表单集合

Dim aForm
For Each aForm In Forms
  If aForm Is Form1 Then
    MsgBox "Found Form1"
  End If
Next

1
如果表单在您的应用程序中,您可以简单地在内部跟踪其状态。毕竟,您控制着代码中可以创建或销毁它的点。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接