共用方式為


IAccessible::get_accChild

The IAccessible::get_accChild method retrieves an IDispatch interface pointer for the specified child, if one exists. All objects must support this property.

For more information about COM parameter attributes, allocating memory, and freeing memory, see Definitions of Parameter Attributes.

HRESULT get_accChild(
VARIANTvarChildID,IDispatch** ppdispChild);

Parameters

  • varChildID
    [in] Identifies the child whose IDispatch interface is retrieved. For more information about initializing the VARIANT structure, see How Child IDs Are Used in Parameters.
  • ppdispChild
    [out, retval] Receives the address of the child object's IDispatch interface.

Return Values

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.

Error Description
S_FALSE Indicates that the child is not an accessible object.
E_INVALIDARG An argument is invalid.

Remarks

Servers expose elements as either elements (child IDs) or full objects (IAccessible interface pointers). If a child is an element, get_accChild returns S_FALSE, and the parent will provide information for that child. If the child is a full object, get_accChild will return the IAccessible interface pointer and the parent will not provide information about that child. If get_accChild fails because the server application cannot create an accessible object due to a temporary system error (such as an out-of-memory error), the server should return a suitable failure code.

Note to server developers  If varChildID contains VT_EMPTY, you should return E_INVALIDARG.

Server Example

The following example code shows an implementation for an object that does not have any children, or whose children are elements rather than objects.

HRESULT STDMETHODCALLTYPE AccServer::get_accChild( 
    VARIANT varChild,
    IDispatch **ppdispChild)
{
    if (varChild.vt != VT_I4)
    {
        *ppdispChild = NULL;
        return E_INVALIDARG;
    }
    *ppdispChild = NULL;    
    return S_FALSE;     
};

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

IAccessible::get_accParent, AccessibleChildren, VARIANT Structure, IDispatch Interface, Object Navigation Properties and Methods