Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

WindowFromAccessibleObject (oleacc)
 
.
Summary

The WindowFromAccessibleObject function retrieves the window handle that corresponds to a given instance of an IAccessible interface.

C# Signature:

[DllImport("oleacc.dll")]
public static extern uint WindowFromAccessibleObject(IAccessible pacc, ref IntPtr phwnd );

VB .NET Signature:

Declare Function WindowFromAccessibleObject Lib "oleacc.dll" (ByVal pacc as IAccessible, ByRef phwnd as IntPtr) As Integer

User-Defined Types:

None.

Sample Code c#:

   //MouseHook.POINT structure type of POINT
    public class Miscelanious
    {
    static Accessibility.IAccessible iAccessible;//interface: Accessibility namespace
    static Accessibility.IAccessible iAccessible;
    static object ChildId;
    public static IntPtr GetControlHandlerFromPoint(MouseHook.POINT location)
    {
        IntPtr handler=IntPtr.Zero;

        handler = AccessibleObjectFromPoint(location,out iAccessible,out ChildId);
        WindowFromAccessibleObject(iAccessible, ref handler);
        return handler;

    }
    public static string GetText()
    {
        if (iAccessible != null && ChildId != null)
        {
        return iAccessible.get_accName(ChildId);
        }
        else return "none";

    }


    #region DLLIMPORT

    [DllImport("oleacc.dll")]
    public static extern IntPtr AccessibleObjectFromPoint(MouseHook.POINT pt, [Out, MarshalAs(UnmanagedType.Interface)] out IAccessible accObj, [Out] out object ChildID);

    [DllImport("oleacc.dll")]
    public static extern uint WindowFromAccessibleObject(IAccessible pacc, ref IntPtr phwnd);
    #endregion
    }

Tips & Tricks:

If you are calling this API from .NET Framework version 2.0 or higher, be sure to put the STAThread attribute on your main(), or manually set the ApartmentState property of the thread you are calling this from to ApartmentStates.STA, or you will get an error code of 0x8001010D which is a “cannot call out exception because of an input synchronous call”.

Sample Code:

Please add some!

Alternative Managed API:

The ManagedWindowsApi project (http://mwinapi.sourceforge.net) provides a SystemAccessibleObject class to access accessible objects and handle accessible events.

TODO

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions