RECT client={};
GetClientRect(ghApp, &client);
LIF(pVW->SetWindowPosition(client.left, client.top, client.right, client.bottom));
LIF(CorrectAspectRatio(pVideoRender));
// Undo change of message drain
LIF(pVW->put_MessageDrain((OAHWND) hDrain));
LIF(pVW->put_Visible(OATRUE));
// Reset video window
LIF(pVW->SetWindowForeground(-1));
// Reclaim keyboard focus for player application
UpdateWindow(ghApp);
SetForegroundWindow(ghApp);
SetFocus(ghApp);
g_bFullscreen = FALSE;
}
return hr;
}
And are help functions:
HRESULT GetVideoRenderer(IGraphBuilder *pGraphBuilder, CComPtr& pVideoRender)
{
pVideoRender.Release();
CheckPointer(pGraphBuilder, E_POINTER);
HRESULT hr = S_FALSE; //The renderer is not found.
CComPtr pEnum;
CComPtr pFilter;
ULONG ulFetched = 0;
// Get filter enumerator
hr = pGraphBuilder->EnumFilters(&pEnum);
if (FAILED(hr)){
return hr;
}
hr = pEnum->Reset();
if (FAILED(hr)){
return hr;
}
// Enumerate all filters in the graph
while( (pEnum->Next(1, &pFilter, &ulFetched) == S_OK))
{
CComPtr pIBasicVideo;
hr = pFilter->QueryInterface(IID_IBasicVideo, reinterpret_cast(&pIBasicVideo));
if(SUCCEEDED(hr))
{
pVideoRender = pFilter;
return S_OK;
}
pFilter.Release();
}
return E_NOTIMPL;
}
HRESULT GetCurrentMonitorSize(RECT& rcMonitor, CComPtr& pVideoRender)
{
CheckPointer(pVideoRender, E_POINTER);
HRESULT hr = S_OK;
CComPtr pVMRMonitorConfig9;
hr = pVideoRender ->QueryInterface(IID_IVMRMonitorConfig9, reinterpret_cast(&pVMRMonitorConfig9));
if(SUCCEEDED(hr))
{
VMR9MonitorInfo vMonInfo[16] = {}; // Array of VMR9MonitorInfo structures.
DWORD dwNumMonitors = 0; // Number of attached monitors.
UINT dwCutrrentMonitorIndex = 0;
LIF( pVMRMonitorConfig9->GetAvailableMonitors(vMonInfo, 16, &dwNumMonitors) );
rcMonitor = vMonInfo[dwCutrrentMonitorIndex].rcMonitor;
}
else
{
CComPtr pVMRMonitorConfig;
hr = pVideoRender->QueryInterface(IID_IVMRMonitorConfig, reinterpret_cast(&pVMRMonitorConfig));
if(FAILED(hr)){
return hr;
}
VMRMONITORINFO vMonInfo[16] = {}; // Array of VMRMONITORINFO structures.
DWORD dwNumMonitors = 0; // Number of attached monitors.
UINT dwCutrrentMonitorIndex = 0;
LIF( pVMRMonitorConfig->GetAvailableMonitors(vMonInfo, 16, &dwNumMonitors) );
rcMonitor = vMonInfo[dwCutrrentMonitorIndex].rcMonitor;
}
return S_OK;
}
HRESULT CorrectAspectRatio(CComPtr& pVideoRender)
{
CheckPointer(pVideoRender, E_POINTER);
HRESULT hr = S_OK;
CComPtr pIVMRAspectRatioControl9;
hr = pVideoRender ->QueryInterface(IID_IVMRAspectRatioControl9, reinterpret_cast(&pIVMRAspectRatioControl9));
if(SUCCEEDED(hr))
{
LIF( pIVMRAspectRatioControl9->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX) );
}
else
{
CComPtr pIVMRAspectRatioControl;
hr = pVideoRender ->QueryInterface(IID_IVMRAspectRatioControl, reinterpret_cast(&pIVMRAspectRatioControl));
if(FAILED(hr)){
return hr;
}
LIF( pIVMRAspectRatioControl->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX) );
}
return S_OK;
}
IVideoWindow FullScreen Vista Issues
http://social.msdn.microsoft.com/forums/en-US/windowsdirectshowdevelopment/thread/cd515f32-87f4-4726-a07d-f995fa521e1f/
1. DirectX Summer 2004 SDK has the most samples (recommended for this and other reasons on my site):
C:\DXSDK\9_0\Samples\C++\DirectShow\Players\PlayWnd
2. VMR7 and VMR9 are not obsolete. However, some of us have written our own custom renderers because the stock renderers have limitations that we cannot live with. EVR has its limitations too.
3. The full screen vs. creating a borderless window the size of the screen comes up from time to time. I prefer the latter because fullscreen mode has issues. In the old days, when graphics cards had more problems stretching video in windowed mode, it was good to have fullscreen alternative.
http://tmhare.mvps.org/