如何根据控件的句柄得到控件的Name属性?
以及其他所有属性!!!

解决方案 »

  1.   

    似乎只能遍历所有Controls,然后查找拥有匹配句柄的控件,然后再用类型库获得其所有属性……
      

  2.   

    给我EMAIL:
    [email protected]
    因为,程序太长了。
      

  3.   

    可以获取上面的内容,但要获取name属性,恐怕不可行。
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
    Private Sub Form_Activate()
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim MyStr As String
        'Create a buffer
        MyStr = String(100, Chr$(0))
        'Get the windowtext
        GetWindowText Me.hwnd, MyStr, 100
        'strip the rest of buffer
        MyStr = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
        'Triple the window's text
        MyStr = MyStr + MyStr + MyStr
        'Set the new window text
        SetWindowText Me.hwnd, MyStr
    End Sub
      

  4.   

    supergreenbean(超级绿豆) 的想法可行,但楼主的意思,这个控件是不是外部程序的?
      

  5.   

    To kissoflife:
        对是外部程序的
      

  6.   

    外部程序不会提供你一个封装好的Control对象……
      

  7.   

    那该怎么办?我看到别人的程序能取得vb控件的所有属性,包括name