Share via


IAccessible::accSelect

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.

HRESULT accSelect(
longflagsSelect,VARIANTvarID);

Parameters

  • flagsSelect
    [in] Specifies which selection or focus operations are to be performed. This parameter must have a combination of the values from the SELFLAG enumerated type.
  • varID
    [in] Specifies the selected object. This parameter is either CHILDID_SELF (to select the object itself) or a child ID (to select one of the object's children). For more information about initializing the VARIANT structure, see How Child IDs Are Used in Parameters.

Return Values

If successful, returns S_OK.

If not successful, returns one of the following values or another standard COM error code.

Error Description
S_FALSE The specified object is not selected.
E_INVALIDARG An argument is invalid. This return value means that the specified SELFLAG combination is invalid, or that the SELFLAG value does not make sense for the specified object. For example, the flags SELFLAG_EXTENDSELECTION, SELFLAG_ADDSELECTION, and SELFLAG_REMOVESELECTION are not allowed on a single-selection list box.
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 or Windows Me.

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

**  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.

See Also

SELFLAG, VARIANT Structure, Selection and Focus Properties and Methods, IAccessible::get_accFocus, IAccessible::get_accSelection