Why IVideoWindow methods aren't working? (C++ DirectShow)

331 Views Asked by At

yesterday I asked this question about DirectShow programming and eventually was able to solve the problem on my own. Once solved, another problem arose: When I play the video it pops up into another window, and I'd like to display it inside my hWnd window. Plus I'd like to make my video play fullscreen and so I typed this code:

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();

but still, even if everything compiles fine, I won't achieve the desired results. I even tried to test if IVideoWindow methods worked by putting

window->HideCursor(OATRUE);

but my cursor still appears and even other methods won't have any effect. What could cause this weird behaviour, and how could I solve?

Thanks in advance!

0

There are 0 best solutions below