Win7下 directshow 窗口模式退出全屏后黑屏,使用的方法是put_FullScreenMode,据说是因为win7的桌面组合效果导致的。
推荐使用无窗口模式。
解决方法:改为无窗口或仿真全屏。
仿真全屏:
HRESULT PlayVideo::PutFullScreen(HWND ghApp)
{
HRESULT hr=S_OK;
if (!bFullscreen)
{
// Save current message drain
pVidWin->get_MessageDrain((OAHWND)NULL);
// Set message drain to application main window
pVidWin->put_MessageDrain((OAHWND) ghApp);
pVidWin->put_Owner( (OAHWND) NULL);
pVidWin->put_WindowStyle(0);
pVidWin->put_WindowStyleEx(WS_EX_TOPMOST | WS_POPUP);
pVidWin->SetWindowPosition(0,0,GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN));//全屏显示
bFullscreen = TRUE;
}
else
{
pVidWin->put_MessageDrain((OAHWND)NULL);
pVidWin->put_Visible(OAFALSE);
pVidWin->put_Owner((OAHWND)Owner);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS|WS_CLIPCHILDREN);
pVidWin->SetWindowForeground(OATRUE);
OnSize();//调整视频窗口大小
bFullscreen = FALSE;
}
return hr;
}
void PlayVideo::OnSize()
{
HWND hwnd;
CWnd *pcwnd;
CRect rect;
pVidWin->get_Owner((OAHWND*)&hwnd);
pcwnd=CWnd::FromHandle(hwnd);
pcwnd->GetClientRect(&rect);
pVidWin->SetWindowPosition(rect.left ,rect.top ,
rect.right ,rect.bottom );
}
推荐使用无窗口模式。
http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/b8bf047d-8353-4b32-89a5-776bec85cb17/