다음을 통해 공유


Using the IVideoWindow Interface (Windows CE 5.0)

Send Feedback

This section describes how to use the IVideoWindow interface 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 topic. In particular, the functions WindowProc and WinMain contain 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::RenderFile method). For more information on how to do this, see Playing a Media File.

Then, before starting playback, set the properties on the video window, as follows:

Attach the video playback window to the desired parent window. To do this, call the IVideoWindow::put_Owner method and pass it a handle to the owner window. This method takes a variable of type OAHWND, so cast the handle to this type, if necessary.

Note   To make the following code example easier to read, error checking is not included. Do not use this code example in a release configuration unless it you have modified it to include secure error handling.

// pGraph is a previously obtained pointer to the filter graph manager.
IVideoWindow    *pVidWin = NULL;
pGraph->QueryInterface(IID_IVideoWindow, (void **)&pVidWin);
pVidWin->put_Owner((OAHWND)g_hwnd);

Change the style of the video window to a child window. To do this, call the IVideoWindow::put_WindowStyle method and pass it a combination of style flags. The WS_CHILD flag indicates that the window is a child window; the WS_CLIPSIBLINGS flag prevents the window from drawing inside the client area of another child window.

pVidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);

Set the position of the video window by calling the IVideoWindow::SetWindowPosition method. 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 GetClientRect function fills a RECT structure with the coordinates of the window's client area. The coordinates are relative to the upper-left corner of the client area, so the left and top members are both zero and the right and bottom members 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);   

See Also

Setting the Video Window

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.