Example #1
0
/*++

Routine Name:

    CDocPropPage::PublishHelpToControls

Routine Description:

    Propagate any useful interfaces used in this class down to the collection of control handlers.
    This allows access to these helper interfaces in the control handlers classes.

Arguments:

    None

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CDocPropPage::PublishHelpToControls(
    VOID
    )
{
    ASSERTMSG(m_pDriverUIHelp != NULL, "NULL pointer to driver UI help interface.\n");
    ASSERTMSG(m_pOemCUIPParam != NULL, "NULL pointer to OEMCUIPPARAM structure.\n");
    ASSERTMSG(m_pUIProperties != NULL, "NULL pointer to CUIProperties.\n");

    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(m_pDriverUIHelp, E_PENDING)) &&
        SUCCEEDED(hr = CHECK_POINTER(m_pOemCUIPParam, E_PENDING)) &&
        SUCCEEDED(hr = CHECK_POINTER(m_pUIProperties, E_PENDING)))
    {
        try
        {
            //
            // Iterate over all controls and report the helper interfaces
            //
            if (!m_UIControls.empty())
            {
                UIControlMap::iterator iterUIComponents = m_UIControls.begin();

                while (iterUIComponents != m_UIControls.end())
                {
                    CUIControl* pControl = iterUIComponents->second;

                    if (SUCCEEDED(hr = CHECK_POINTER(pControl, E_POINTER)) &&
                        SUCCEEDED(hr = pControl->SetPrintOemDriverUI(m_pDriverUIHelp)) &&
                        SUCCEEDED(hr = pControl->SetUIProperties(m_pUIProperties)) &&
                        SUCCEEDED(hr = pControl->SetOemCUIPParam(m_pOemCUIPParam)))
                    {
                        iterUIComponents++;
                    }
                }

            }
        }
        catch (exception& DBG_ONLY(e))
        {
            ERR(e.what());
            hr = E_FAIL;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}