Microsoft DirectX 8.1 (C++)

Configuring For Windowless Mode

This topic applies to Windows XP Home Edition and Windows XP Professional only.

To configure the VMR for windowless mode, first create the filter and add it to the graph. Then, before connecting any pins, call IVMRFilterConfig::SetRenderingMode to specify windowless mode. If multiple input streams are desired, specify the number in a call to IVMRFilterConfig::SetNumberOfStreams and then use the IVMRVideoStreamControl interface on each pin if you need to set the Z-order and other parameters. Next, use the IVMRWindowlessControl interface methods to position the video rectangle in the application window's client area. Applications notify the VMR which window handle to use via the IVMRWindowlessControl::SetVideoClippingWindow method.

The following code shows how to create a VMR filter, add it to the DirectShow filter graph, and then put the VMR into windowless mode:

HRESULT InitializeWindowlessVMR(
    HWND hwndApp,         // Application window.
    IFilterGraph* pFG,    // Pointer to the Filter Graph Manager.
    IVMRWindowlessControl** ppWc,  // Receives. 
    DWORD dwNumStreams,  //  Number of streams to use.
    BOOL fBlendAppImage  //  
    )
{
    IBaseFilter* pVmr = NULL;
    IVMRWindowlessControl* pWc = NULL;
    *ppWc = NULL;

    // Create the VMR and add it to the filter graph.
    HRESULT hr = CoCreateInstance(CLSID_VideoMixingRenderer, NULL,
                     CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVmr);
    if (SUCCEEDED(hr)) 
    {
        hr = pFG->AddFilter(pVmr, L"Video Mixing Renderer");
        if (SUCCEEDED(hr)) 
        {
            // Set the rendering mode and number of streams.  
            IVMRFilterConfig* pConfig;
            hr = pVmr->QueryInterface(IID_IVMRFilterConfig, 
                        (void**)&pConfig);
            if( SUCCEEDED(hr)) 
            {
                pConfig->SetRenderingMode(VMRMode_Windowless);
                if (dwNumStreams > 1 || fBlendAppImage) 
                {
                    pConfig->SetNumberOfStreams(dwNumStreams);
                }
                pConfig->Release();
            }
            hr = pVmr->QueryInterface(IID_IVMRWindowlessControl,
                    (void**)&pWc);
            if( SUCCEEDED(hr)) 
            {
                pWc->SetVideoClippingWindow(hwndApp);
                pWc->Release();
                *ppWc = pWc;
            }
        }
        pVmr->Release();
    }
    return hr;
}

In addition to notifying the VMR of the playback window, applications should also notify the VMR of two Windows messages, WM_PAINT and WM_DISPLAYCHANGE. On receiving either of these messages the application should call the IVMRWindowlessControl::RepaintVideo and IVMRWindowlessControl::DisplayModeChanged methods respectively.

The following sample applications demonstrate the concepts discussed in this topic: