internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild) { WindowsToolbar wtv = null; // By calling Accessible.CreateNativeFromEvent() instead of AccessibleObjectFromWindow() only controls with a native // implementation of IAccessible will be found. OleAcc will not create a IAccessible proxy, since // Accessible.CreateNativeFromEvent() by passes OleAcc by sending a WM_GETOBJECT directly to the control and creating // IAccessible from the return, if it can. Accessible acc = Accessible.CreateNativeFromEvent(hwnd, NativeMethods.OBJID_CLIENT, NativeMethods.CHILD_SELF); if (acc != null) { AccessibleRole role = acc.Role; if (role == AccessibleRole.MenuBar || role == AccessibleRole.MenuPopup) { wtv = new WindowsToolbarAsMenu(hwnd, null, 0, acc); } } if (wtv == null) { wtv = new WindowsToolbar(hwnd, null, 0); } return(idChild == 0 ? wtv : wtv.CreateToolbarItem(idChild - 1)); }
internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild) { WindowsToolbar wtv = null; // By calling Accessible.CreateNativeFromEvent() instead of AccessibleObjectFromWindow() only controls with a native // implementation of IAccessible will be found. OleAcc will not create a IAccessible proxy, since // Accessible.CreateNativeFromEvent() by passes OleAcc by sending a WM_GETOBJECT directly to the control and creating // IAccessible from the return, if it can. Accessible acc = Accessible.CreateNativeFromEvent(hwnd, NativeMethods.OBJID_CLIENT, NativeMethods.CHILD_SELF); if (acc != null) { AccessibleRole role = acc.Role; if (role == AccessibleRole.MenuBar || role == AccessibleRole.MenuPopup) { wtv = new WindowsToolbarAsMenu(hwnd, null, 0, acc); } } if( wtv == null) { wtv = new WindowsToolbar(hwnd, null, 0); } return idChild == 0 ? wtv : wtv.CreateToolbarItem (idChild - 1); }