Export (0) Print
Expand All

IAccessible::get_accSelection method

The IAccessible::get_accSelection method retrieves the selected children of this object. All objects that support selection must support this property.

Syntax


HRESULT get_accSelection(
  [out, retval]  VARIANT *pvarChildren
);

Parameters

pvarChildren [out, retval]

Type: VARIANT*

Address of a VARIANT structure that receives information about which children are selected. The following table describes the information returned in pvarChildren.

vt memberValue member
VT_EMPTY

No children are selected.

VT_DISPATCH

One child object is selected, and the address of its IDispatch interface is set in the pdispVal member.

VT_I4

lVal contains the child ID of the child element that is selected. If lVal is CHILDID_SELF, this means that the object itself is selected.

VT_UNKNOWN

Multiple child objects are selected, and the punkVal member contains the address of the IUnknown interface. The client queries this interface for the IEnumVARIANT interface, which it uses to enumerate the selected objects.

 

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. Servers return these values, but clients must always check output parameters to ensure that they contain valid values. For more information, see Checking IAccessible Return Values.

ErrorDescription
DISP_E_MEMBERNOTFOUND

The object does not support this property.

 

Remarks

This method must support the IEnumVARIANT interface.

This method returns either an IDispatch interface pointer or a child ID for the pvarChildren parameter. 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.

Note:   This method retrieves a selected item, not selected text.

Server Example

The following example code shows a possible implementation of this method for a custom single-selection list box. Its GetSelectedIndex method returns -1 if no item is selected.



// m_pControl is the control that returns this accessible object. 

HRESULT STDMETHODCALLTYPE AccServer::get_accSelection(VARIANT *pvarChildren)
{
    int childID = m_pControl->GetSelectedIndex() + 1; // Convert from 0-based. 
    if (childID <= 0)
    {
        pvarChildren->vt = VT_EMPTY;
    }
    else 
    {
        pvarChildren->vt = VT_I4;
        pvarChildren->lVal = childID;
    }
    return S_OK;
};





Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Redistributable

Active Accessibility 1.3 RDK on Windows NT 4.0 with SP6 and later and Windows 95

Header

Oleacc.h

Library

Oleacc.lib

DLL

Oleacc.dll

See also

IAccessible
IAccessible::accSelect
IAccessible::get_accFocus
VARIANT
IDispatch
Selection and Focus Properties and Methods

 

 

Community Additions

ADD
Show:
© 2014 Microsoft