Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This section describes how to use the IVideoWindowinterface to set properties on the video window, including the owner and style of the window.
Note Most of the code in the sample program performs standard windowing operations, and is not discussed in this article. In particular, the functions WindowProcand WinMaincontain a typical framework for Microsoft Windows applications. The application-defined functions PlayFile and CleanUp are the ones of interest.
First, create an instance of the filter graph manager and construct the filter graph (through a call to the IGraphBuilder::RenderFilemethod). For more information on how to do this, see How to Play a File.
Then, before starting playback, set the properties on the video window, as follows:
IVideoWindow *pVidWin = NULL; pVidWin->put_Owner((OAHWND)g_hwnd);
pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
Set the position of the video window by calling the IVideoWindow::SetWindowPositionmethod. This method takes device coordinates specifying the left edge (x-axis), top edge (y-axis), width, and height of the window. The sample program stretches the video window to fill the entire parent window:
RECT grc; GetClientRect(g_hwnd, &grc); pVidWin->SetWindowPosition(0, 0, grc.right, grc.bottom);
The GetClientRectfunction fills a RECTstructure with the coordinates of the window's client area. The coordinates are relative to the upper-left corner of the client area, so the leftand topmembers are both zero and the rightand bottommembers define the width and height, respectively.
Before the application exits, it is important that you set the visibility of the video window to false. Otherwise, a video image remains on the screen and the user cannot get rid of it. Then, reset the owner to NULL; otherwise, messages are sent to the wrong window, likely causing errors.
HRESULT hr = pVidWin->put_Visible(OAFALSE); hr = pVidWin->put_Owner(NULL);
Last updated on Tuesday, May 18, 2004