まず、これを ActiveX コントロールのコンストラクターに追加します。
// this seemingly innocent line is _extremely_ important.
// This causes the window for the control to be created
// otherwise, you won't get an hWnd to render to!
m_bWindowOnly = true;
ActiveX コントロールには、レンダー ターゲットとして使用できる m_hWnd というメンバー変数があります。m_bWindowOnly 変数を true に設定しないと、ActiveX コントロールは独自のウィンドウを作成しません。
最後に、レンダラー (VMR9 など) を選択します。
CRect rcClient;
CComPtr<IBaseFilter> spRenderer;
CComPtr<IVMRWindowlessControl9> spWindowless;
// Get the client window size
::GetClientRect(m_hWnd, rcClient);
// Get the renderer filter
spRenderer.Attach( m_pGraph->GetVideoRenderer() );
if( ! spRenderer )
return E_POINTER;
spWindowless = spRenderer;
if( spWindowless )
{
spWindowless->SetVideoClippingWindow( m_hWnd );
spWindowless->SetVideoPosition(NULL, rcClient);
spWindowless.Release();
}
spRenderer.Detach();
私のグラフ オブジェクトはカスタム オブジェクトであり、GetVideoRenderer() は私自身の関数の 1 つであることに注意してください。これは IBaseFilter* を返します。
これを見つけるのに何年もかかりました。ATL は優れたテクノロジであるため、文書化されていないことは残念です。とにかく、これが役に立てば幸いです!