i
i
i
i
i
i
i
i
15.3. A Movie Player 397
.. // add these lines of code to PlayMovieInWindow(..)
RECT rect;
GetClientRect(ghApp, &rect);
// get an interface for passing commands to the video output window
pGB->QueryInterface(IID_IVideoWindow, (void
**
)&pVW);
// tell DirectShow to render into main window’s client area
pVW->put_Owner((OAHWND)ghApp);
pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
pVW->SetWindowPosition(rect.left, rect.top, rect.right, rect.bottom);
// Have the graph signal events
pME->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0));
.. //
..//add these lines to the code for CloseInterfaces(..)
hr = pVW->put_Visible(OAFALSE); // Relinquish ownership (IMPORTANT!)
hr = pVW->put_Owner(NULL); // no wnser
// Disable event callbacks
hr = pME->SetNotifyWindow((OAHWND)NULL, 0, 0);
SAFE_RELEASE(pME); // Release DirectShow interfaces
SAFE_RELEASE(pVW); // SAFE_RELEASE is a DS macro
..//
..// add these functions to the code
void MoveVideoWindow(void){ // new function to handle size changes
// Track the movement of the window being drawn into and resize if needed
if(pVW){
RECT client;
GetClientRect(ghApp, &client);
hr = pVW->SetWindowPosition(client.left,client.top,
client.right,client.bottom);
}
}
HRESULT HandleGraphEvent(void){ // new functions to handle graph events
LONG evCode, evParam1, evParam2;
HRESULT hr=S_OK;
if (!pME) return S_OK; // Otherwise process all queued events
while(SUCCEEDED(pME->GetEvent(&evCode,&evParam1,&evParam2,0))){
//
// handle any event codes here !!!!!!!!!!!!!!!
//
// Free memory associated with callback - required behaviour
hr = pME->FreeEventParams(evCode, evParam1, evParam2);
}
return hr;
}
Listing 15.3. Changes required to make the renderer filter play the movie within the
application’s client area.