ISelectionContainer::CountObjects

Returns the total number of objects or the number of objects selected.

HRESULT CountObjects(
DWORD dwFlags,
ULONG *pc
);

Parameters

dwFlags

[in] Flag specifying which count to return, either GETOBJS_ALL or GETOBJS_SELECTED.

pc

[out] Number of objects returned.

Return Values

The return value obtained from HRESULT is one of the following:

Return Value

Meaning

S_OK

Success.

E_INVALIDARG

One or more of the arguments is invalid.


Comments

The ActiveX designer implements this method.

If the caller specifies GETOBJS_ALL, the CountObjects method returns the total number of objects in the selection container. If the caller specifies GETOBJS_SELECTED, the method returns the total number of selected objects in the container.

Example

The following example implements CountObjects for a simple container:

STDMETHODIMP CMySelectionContainer::CountObjects
(
    DWORD dwFlags, 
    ULONG * pc
)
{
    if (GETOBJS_ALL == dwFlags) {
        // |objects| + 1 for the container.
        *pc = m_state.dwObjectCount + 1; 
        }
    else {
        // Either the container or one of the objects is always 
        // selected.
        *pc = 1;
    }
    return S_OK;
}