2011/02/14

access2010 IAccessible.accLocationメソッド(oleacc)

Option Compare Database
Option Explicit

Const CHILDID_SELF = 0&

Declare PtrSafe Function AccessibleObjectFromWindow Lib "oleacc" ( _
                                ByVal hWnd As LongPtr, _
                                ByVal dwId As Long, _
                                riid As Any, _
                                ByRef ppvObject As IAccessible _
                                ) As Long

Declare PtrSafe Function IIDFromString Lib "ole32" ( _
                                ByVal lpsz As LongPtr, _
                                lpiid As Any _
                                ) As Long

Declare PtrSafe Function FindWindowEx Lib "user32" _
                                Alias "FindWindowExA" ( _
                                ByVal hWnd1 As LongPtr, _
                                ByVal hWnd2 As LongPtr, _
                                ByVal lpsz1 As String, _
                                ByVal lpsz2 As String _
                                ) As LongPtr

Function ODocTabsHwnd() As LongPtr
    Dim pHwnd As LongPtr
    pHwnd = FindWindowEx(Application.hWndAccessApp, _
                         0, _
                         vbNullString, _
                         "ODocTabs")
    pHwnd = FindWindowEx(pHwnd, _
                         0, _
                         "NetUIHWND", _
                         vbNullString)
    ODocTabsHwnd = pHwnd
End Function

Sub DocumentTabsPos()
    Dim IID(0 To 3) As Long, acc As IAccessible
    Dim xLeft As Long, yTop As Long, _
        xWidth As Long, yHeight As Long
    
    IIDFromString StrPtr("{618736E0-3C3D-11CF-810C-00AA00389B71}"), _
                  IID(0)
    AccessibleObjectFromWindow ODocTabsHwnd, _
                               CHILDID_SELF, _
                               IID(0), _
                               acc
    acc.accLocation xLeft, yTop, xWidth, yHeight
    Debug.Print xLeft, yTop, xWidth, yHeight
End Sub

0 件のコメント: