窗体句柄已经知道了,可以通过此句柄,枚举出其内的各类控件的句柄吗?
比如文本框类,和按钮类,菜单类及子菜单。
能帮帮忙吗?

解决方案 »

  1.   

    EnumChildWindows() API或者 
    For Each Item In Me.Controls
        If Item Is TextBox
            MsgBox Item.hWnd
        End If
        ...
        ' 这里可以递归调用
    Next
      

  2.   

    老大可以在详细一点吗?谢谢了
    我的MSDN里 怎么没有 API函数 和windows程序呢
      

  3.   

    给你个源码的链接参考一下吧:
    http://download.csdn.net/source/160152
      

  4.   

    参考:
    http://topic.csdn.net/u/20090316/18/29aa77dd-c789-4f89-a7db-b4e274e0fcab.html
      

  5.   

    使用FindWindow+FindWindowEx或者GetWindow都行。
      

  6.   

    使用GetWindow的代码如下:Option ExplicitPrivate Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Const GW_HWNDNEXT = 2
    Private Const GW_HWNDPREV = 3
    Private Const GW_CHILD = 5
    Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As LongPrivate Sub Form_Load()
        EnumChild Me.hwnd
    End SubPublic Sub EnumChild(ByVal hParent As Long)
        Dim hChild As Long
        Dim lRet As Long
        Dim strClassName As String
        
        hChild = GetWindow(hParent, GW_CHILD)
        Do While hChild <> 0
            strClassName = String(200, vbNullChar)
            lRet = GetClassName(hChild, strClassName, Len(strClassName))
            strClassName = Left(strClassName, lRet)
            Debug.Print hChild, strClassName
            Call EnumChild(hChild)
            hChild = GetWindow(hChild, GW_HWNDNEXT)
        Loop
    End Sub
      

  7.   

    顶一下!
    是不是用 FindWindow 和 GetWindow 呀 ~