|
|
Title | Get information about all of a control's properties |
Keywords | control property, property information, TypeLib |
Categories | Controls, Software Engineering |
|
|
Thanks to Oigres P.
Set a project reference to the TypeLib Information library. Create a TLIApplication object and get an InterfaceInfo object for the control from its InterfaceInfoFromObject function. Then iterate through the interface's members.
|
|
Private Sub Command1_Click()
''caution crashes if you try to read the Form1
' properties
iterateMembers Text1
End Sub
Sub iterateMembers(obj As Object)
'iterate the members in the textbox interface
'put them in a flexgrid for viewing
Dim TLI As New TLIApplication, ret As Variant
Dim interface As InterfaceInfo
Dim member As MemberInfo
On Error Resume Next
Set interface = TLI.InterfaceInfoFromObject(obj)
Dim index As Long, tempstr As String
ReDim str(interface.Members.Count) As String
index = 0
For Each member In interface.Members
tempstr = ""
tempstr = tempstr & member.Name & vbTab & _
member.VTableOffset & vbTab & _
Hex$(member.MemberId) & _
vbTab & member.HelpString
'get property value; using memberID is faster than
' member.Name
ret = TLI.InvokeHook(Text1, member.MemberId, _
INVOKE_PROPERTYGET)
'adjust long values; convert to hex (else shows neg
' value)
If TypeName(ret) = "Long" Then
ret = "&H" & Hex(ret) & "&"
tempstr = tempstr & vbTab & ret & vbTab & "long"
Else
tempstr = tempstr & vbTab & ret & vbTab & _
TypeName(ret)
End If
'store row data in array
str(index) = tempstr
index = index + 1
Next
Set TLI = Nothing
fillGrid str()
End Sub
|
|
|
|
|
|