The IAccessible::get_accFocus method retrieves the object that has the keyboard focus. All objects that receive the keyboard focus must support this property.
For more information about COM parameter attributes, allocating memory, and freeing memory, see Definitions of Parameter Attributes.
HRESULT get_accFocus( VARIANT* pvarID );
[out, retval] Address of a VARIANT structure that receives information about the object that has the focus. The following table describes the information returned in pvarID.
vt member Value member VT_EMPTY None. This object does not have the keyboard focus itself and does not contain a child that has the keyboard focus. VT_I4 lVal is CHILDID_SELF. The object itself has the keyboard focus. VT_I4 lVal contains the child ID of the child element with the keyboard focus. VT_DISPATCH pdispVal member is the address of the IDispatch interface for the child object with the keyboard focus.
If successful, returns S_OK.
If not successful, returns one of the following values or another standard COM error code. Although servers return these values, clients must always check output parameters to ensure that they contain valid values. For more information, see Checking IAccessible Return Values.
|S_FALSE||The window that contains this object is not the active window.|
|DISP_E_MEMBERNOTFOUND||The object does not support this property.|
The concept of keyboard focus is related to that of an active window. An active window is the foreground window on which the user works. The object with the keyboard focus is either the active window or a child object of the active window.
Only one object or item within a container has the focus at any one time. The object with the keyboard focus is not always the selected object. For more information about the difference between selection and focus, see Selection and Focus Properties and Methods.
This method returns either an IDispatch interface pointer or a child ID for the pvarID. For more information about how to use the IDispatch interface pointer or child ID, see How Child IDs Are Used in Parameters.
As with other IAccessible methods and functions, clients might receive errors for IAccessible interface pointers because of a user action. For more information, see Receiving Errors for IAccessible Interface Pointers.
** Windows NT/2000/XP/Server 2003:** Included in Windows 2000 and later.
** Windows 95/98/Me:** Included in Windows 98 and later.
** Redistributable:** Requires Active Accessibility 1.3 RDK on Windows NT 4.0 SP6 and Windows 95.
** Header:** Declared in Oleacc.h.
** Library:** Use Oleacc.lib.