Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15667

Late binding CUIAutomation

$
0
0
I have the following code which uses IAUtomation to get me the bounding rects of the tabs in a MultiPage control... The code works fine because it uses early binding.

I can't seem to make this work with late binding .. The code errors out at the call of .ElementFromHandle(ByVal hwnd)

Any suggestions ? Thanks.

Code:

Private Function GetPageRect(ByVal Page As Object, ByVal hwnd As Long) As RECT
 
    'A design-time reference to the UIAutomationClient library is required for this routine.
 
    Const UIA_TabItemControlTypeId = &HC363&

    Dim oAutomation As CUIAutomation
    Dim oAllElements As IUIAutomationElementArray
    Dim oElement As IUIAutomationElement
    Dim oCondition As IUIAutomationCondition
    Dim tTagRect As RECT, i As Long
 
    On Error Resume Next
 
    Set oAutomation = New CUIAutomation
    Set oElement = oAutomation.ElementFromHandle(ByVal hwnd)
    Set oCondition = oAutomation.CreateTrueCondition
    Set oAllElements = oElement.FindAll(TreeScope_Descendants, oCondition)
 
    For i = 0 To oAllElements.Length - 1
        Set oElement = oAllElements.GetElement(i)
        If oElement.CurrentControlType = UIA_TabItemControlTypeId Then
            If oElement.CurrentName = Page.Caption Then
                Call CopyMemory(tTagRect, oElement.CurrentBoundingRectangle, LenB(tTagRect))
                GetPageRect = tTagRect
                Call ZeroMemory(tTagRect, ByVal LenB(tTagRect))
                Exit Function
            End If
        End If
    Next i
 
End Function


Viewing all articles
Browse latest Browse all 15667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>