CBasePropertyPage.OnConnect method

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The OnConnect method provides an IUnknown pointer to the object associated with the property page.

Syntax

virtual HRESULT OnConnect(
   IUnknown *pUnknown
);

Parameters

pUnknown

Pointer to the IUnknown interface of the object.

Return value

The base-class implementation returns S_OK.

Remarks

The CBasePropertyPage::SetObjects method calls the OnConnect method. Override this method to store a pointer to the object specified by pUnknown. You can either store the pUnknown pointer itself, or query that pointer for other interfaces. If you store the pUnknown pointer, call AddRef before OnConnect returns.

In the CBasePropertyPage::OnActivate method, use the stored pointer (or pointers) to retrieve initial values for the dialog properties. In the CBasePropertyPage::OnApplyChanges method, apply any changes back to the object. Release all pointers in the CBasePropertyPage::OnDisconnect method.

Examples

HRESULT CMyProp::OnConnect(IUnknown *pUnk)
{
    ASSERT(m_pOwningFilter == NULL);
    HRESULT hr;
    // Query pUnk for the filter's custom interface.
    hr = pUnk->QueryInterface(IID_ISomeCustomInterface,
             reinterpret_cast<void**>(&m_pOwningFilter));
    return hr;
}

Requirements

Requirement Value
Header
Cprop.h (include Streams.h)
Library
Strmbase.lib (retail builds);
Strmbasd.lib (debug builds)

See also

CBasePropertyPage Class