为什么IVideoWindow方法不起作用? (C ++ DirectShow)

时间:2016-05-06 14:42:39

标签: c++ video fullscreen directshow windowed

昨天我问了this关于DirectShow编程的问题,并最终能够自己解决问题。一旦解决,出现了另一个问题:当我播放视频时,它弹出到另一个窗口,我想在我的hWnd窗口中显示它。另外,我想让我的视频全屏播放,因此我输入了以下代码:

IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
IVideoWindow* window = NULL;


HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
    return -1;
}



hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
    return -1;
}

hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
if (FAILED(hr)) {
    MessageBoxW(GetActiveWindow(), L"Errore IMediaControl", L"Attenzione", MB_ICONERROR);
    return -1;
}

hr = pGraph->QueryInterface(IID_IVideoWindow, (void **)&window);
if (FAILED(hr)) {
    MessageBoxW(GetActiveWindow(), L"Errore I video window", L"Attenzione", MB_ICONERROR);
    return -1;
}

window->put_Owner((OAHWND)GetActiveWindow());
window->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX);
RECT rc;
window->put_FullScreenMode(OATRUE);
window->HideCursor(OATRUE);

hr = pGraph->QueryInterface(IID_IMediaEvent, (void**)&pEvent);
if (FAILED(hr)) {
    MessageBoxW(GetActiveWindow(), L"Errore IMediaEvent", L"Attenzione", MB_ICONERROR);
    return -1;
}


hr = pGraph->RenderFile(L"C:\\Users\\Chuck norris\\Desktop\\Equilibrium.avi", NULL);

if (FAILED(hr)) {
    MessageBoxW(GetActiveWindow(), L"Errore IMediaControl", L"Attenzione", MB_ICONERROR);
    return -1;
}
else {
    hr = pControl->Run();
}

window->Release();
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();

但是,即使一切都很好,我也不会达到预期的效果。我甚至尝试通过放置

来测试IVideoWindow方法是否有效
window->HideCursor(OATRUE);

但我的光标仍然出现,甚至其他方法也没有任何效果。 什么可能导致这种奇怪的行为,我怎么能解决?

提前致谢!

0 个答案:

没有答案