IAccessible::accSelect method (oleacc.h)

The IAccessible::accSelect method modifies the selection or moves the keyboard focus of the specified object. All objects that support selection or receive the keyboard focus must support this method.

Syntax

HRESULT accSelect(
  [in] long    flagsSelect,
  [in] VARIANT varChild
);

Parameters

[in] flagsSelect

Type: long

Specifies which selection or focus operations are to be performed. This parameter must have a combination of the SELFLAG Constants.

[in] varChild

Type: VARIANT

Specifies the selected object. If the value is CHILDID_SELF, the object itself is selected; if a child ID, one of the object's child elements is selected. For more information about initializing the VARIANT structure, see How Child IDs Are Used in Parameters.

Return value

Type: HRESULT

If successful, returns S_OK.

If not successful, returns one of the values in the table that follows, or another standard COM error code.

Error Description
S_FALSE
The specified object is not selected.
E_INVALIDARG
An argument is not valid. This return value means that the specified SELFLAG combination is not valid, or that the SELFLAG value does not make sense for the specified object. For example, the following flags are not allowed on a single-selection list box: SELFLAG_EXTENDSELECTION, SELFLAG_ADDSELECTION, and SELFLAG_REMOVESELECTION.
DISP_E_MEMBERNOTFOUND
The object does not support this method.

Remarks

Client applications use this method to perform complex selection operations. For more information, see Selecting Child Objects. This method provides the simplest way to programmatically switch the input focus between applications. This applies to applications running on Windows 2000.

Note:  This method is for the selection of items, not text.

Client Example

The following example function selects the item at a specified point on the screen. It is assumed that a single selection is wanted.

HRESULT SelectItemAtPoint(POINT point)
{
    VARIANT varItem;
    IAccessible* pAcc;
    HRESULT hr = AccessibleObjectFromPoint(point, &pAcc, &varItem);
    if ((hr == S_OK))
    {
        hr = pAcc->accSelect((SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION), varItem);
        VariantClear(&varItem);
        pAcc->Release();
    }
    return hr;
}

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header oleacc.h
Library Oleacc.lib
DLL Oleacc.dll
Redistributable Active Accessibility 1.3 RDK on Windows NT 4.0 with SP6 and later and Windows 95

See also

IAccessible

IAccessible::get_accFocus

IAccessible::get_accSelection

SELFLAG

Selection and Focus Properties and Methods

VARIANT