The IVideoWindow interface supports the video window properties of a video renderer. It is a dual interface (accessible through Microsoft® Visual Basic® and Visual C++®) that controls a generic video window. Generally, this is a video renderer that draws video into a window on the display.
The IVideoWindow interface supports both properties and methods. Properties are more easily accessible from many Automation controllers (such as Microsoft Visual Basic). However, some operations require several properties to be changed simultaneously; for this reason, methods are provided that allow a number of related properties to be changed simultaneously. For example, setting the window's position and size can be done by four individual put_[property name] calls or by the single method SetWindowPosition.
The methods require only that the video renderer be connected. If it is not connected, all the interface functions return VFW_E_NOT_CONNECTED. Properties set on a video renderer persist between successive connections and disconnections. All applications should ensure that they reset the renderer properties before starting a presentation.
Because this interface is Automation-compatible, there are two important aspects to remember about parameters accepted by these methods. First, all Boolean returns are OAFALSE (0) or OATRUE (1), which is different from the C or C++ definition. Second, all strings are defined as being of type BSTR. All strings sent to the interface should be allocated through the Automation SysAllocString function, and similarly all strings returned from the interface should be freed by using the Automation SysFreeString function.
The video renderer filter supplied with Microsoft® DirectShow® implements this interface. It is also implemented by the filter graph manager (via a plug-in distributor) to pass method calls from the application to the video renderer filter's implementation of the interface.
Implement this interface if you are writing a replacement video renderer filter. You can use the CBaseVideoWindow class, which handles the IDispatch implementation for Automation, to help implement this interface.
This interface is used by applications or other filters that must control the video window's properties.
Methods in Vtable Order
IUnknown methods Description QueryInterface Retrieves pointers to supported interfaces. AddRef Increments the reference count. Release Decrements the reference count. IDispatch methods Description GetTypeInfoCount Determines whether there is type information available for this dispinterface. GetTypeInfo Retrieves the type information for this dispinterface if GetTypeInfoCount returned successfully. GetIDsOfNames Converts text names of properties and methods (including arguments) to their corresponding DISPIDs. Invoke Calls a method or accesses a property in this dispinterface if given a DISPID and any other necessary parameters. IVideoWindow methods Description put_Caption Sets the text caption on the playback window. get_Caption Retrieves the text caption on the playback window. put_WindowStyle Sets the playback window style. get_WindowStyle Retrieves the playback window style. put_WindowStyleEx Sets the style of the control window. get_WindowStyleEx Retrieves the playback window's extended style bits. put_AutoShow Specifies if the window will be automatically shown on the first state change. get_AutoShow Retrieves information about whether the window will be automatically shown. put_WindowState Sets the current window state (such as visible or minimized). get_WindowState Retrieves the current window state (such as visible or minimized). put_BackgroundPalette Informs the renderer to realize its palette in the background. get_BackgroundPalette Retrieves information about whether any palette required will be realized in the background. put_Visible Sets the visibility of the window. get_Visible Retrieves the visibility of the window. put_Left Sets the x-axis coordinate for the video window. get_Left Retrieves the x-axis coordinate for the video window. put_Width Sets the width of the video window. get_Width Retrieves the width of the video window. put_Top Sets the y-axis coordinates for the video window. get_Top Retrieves the y-axis coordinates for the video window. put_Height Sets the height of the video window. get_Height Retrieves the height of the video window. put_Owner Sets the owning parent window for the video playback window. get_Owner Retrieves the owning parent window for the video playback window. put_MessageDrain Specifies a window to which the video window will post messages. get_MessageDrain Retrieves the window set to receive messages from the video window. get_BorderColor Retrieves the border color for the video window. put_BorderColor Sets the border color for the video window. get_FullScreenMode Retrieves the full-screen rendering mode of the video renderer filter supporting this interface. put_FullScreenMode Sets the full-screen mode for the video renderer filter supporting this interface. SetWindowForeground Tells the renderer filter to become the foreground window. NotifyOwnerMessage Forwards messages that have been received by a parent window to a child window owned by a filter. SetWindowPosition Sets the video window position on the display. GetWindowPosition Retrieves the video window position. GetMinIdealImageSize Retrieves the ideal minimum image size for the video image playback (client) area. GetMaxIdealImageSize Retrieves the ideal maximum image size for the video image playback (client) area. GetRestorePosition Retrieves the normal restored window dimensions. HideCursor Hides the cursor. IsCursorHidden Determines if the cursor is hidden or showing.
Retrieves information about whether the window will be automatically shown.
Syntax
HRESULT get_AutoShow( long *AutoShow );
Parameters
- AutoShow
- [out] Pointer to a value indicating whether the window will be automatically shown. OATRUE indicates that the window will be made visible when the state is changed to the paused or running state.
Return Value
Returns an HRESULT value.
Retrieves information about whether any palette required will be realized in the background.
Syntax
HRESULT get_BackgroundPalette( long *pBackgroundPalette );
Parameters
- pBackgroundPalette
- [out] Pointer to a value indicating whether the palette will be realized in the background; OATRUE indicates that it will.
Return Value
Returns an HRESULT value.
Retrieves the border color for the video window.
Syntax
HRESULT get_BorderColor( long *pColor );
Parameters
- pColor
- [out] Pointer to the retrieved border color as a Microsoft Win32® COLORREF value.
Return Value
Returns an HRESULT value.
Retrieves the textual title string for the video window.
Syntax
HRESULT get_Caption( BSTR *strCaption );
Parameters
- strCaption
- [out] Pointer to the retrieved window title caption.
Return Value
Returns an HRESULT value.
Retrieves the full-screen rendering capabilities of the renderer filter supporting this interface.
Syntax
HRESULT get_FullScreenMode( long *FullScreenMode );
Parameters
- FullScreenMode
- [out] Pointer to a value indicating whether the renderer has full-screen capabilities; OATRUE if it supports full-screen video, or OAFALSE if not.
Return Value
Returns an HRESULT value.
Remarks
This method is called by the filter graph manager when asked to render the video to full-screen size. If the renderer does not have inherent support for full-screen playback, it should return E_NOTIMPL. Otherwise, it should return NOERROR. If the renderer does support full-screen playback, this method determines if it is currently switched on or off.
Retrieves the height of the video window.
Syntax
HRESULT get_Height( long *pHeight );
Parameters
- pHeight
- [out] Pointer to the retrieved vertical dimension of the video window.
Return Value
Returns an HRESULT value.
Retrieves the x-axis coordinate for the video window.
Syntax
HRESULT get_Left( long *pLeft );
Parameters
- pLeft
- [out] Pointer to the x-axis coordinate to be retrieved.
Return Value
Returns an HRESULT value.
Retrieves the ideal maximum image size for the video image playback (client) area.
Syntax
HRESULT GetMaxIdealImageSize( long *pWidth, long *pHeight );
Parameters
- pWidth
- [out] Pointer to the image width, in pixels.
- pHeight
- [out] Pointer to the image height, in pixels.
Return Value
Returns an HRESULT value.
Retrieves the window set to receive messages from the video window.
Syntax
HRESULT get_MessageDrain( OAHWND *Drain );
Parameters
- Drain
- [in] Pointer to the window currently assigned to receive messages from the video window.
Return Value
Returns an HRESULT value.
Remarks
The IVideoWindow::put_MessageDrain description contains a list of the Microsoft Win32® messages passed to the window that is specified as a message drain.
Retrieves the ideal minimum image size for the video image playback (client) area.
Syntax
HRESULT GetMinIdealImageSize( long *pWidth, long *pHeight );
Parameters
- pWidth
- [out] Pointer to the image width, in pixels.
- pHeight
- [out] Pointer to the image height, in pixels.
Return Value
Returns an HRESULT value.
Retrieves the owning parent for the video window.
Syntax
HRESULT get_Owner( OAHWND *pOwner );
Parameters
- pOwner
- [out] Pointer to the retrieved window handle.
Return Value
Returns an HRESULT value.
Retrieves the normal restored window dimensions.
Syntax
HRESULT GetRestorePosition( long *pLeft, long *pTop, long *pWidth, long *pHeight );
Parameters
- pLeft
- [out] Pointer to the left x-axis coordinate of the window.
- pTop
- [out] Pointer to the top y-axis coordinate of the window.
- pWidth
- [out] Pointer to the width of the window, in pixels.
- pHeight
- [out] Pointer to the height of the window, in pixels.
Return Value
Returns an HRESULT value.
Remarks
When the window is maximized or minimized, the window position methods return the actual window size. This method returns the dimensions that the window would be when restored. It is useful for applications that want to save a window state while the window is maximized or minimized.
Retrieves the y-axis coordinate of the video window.
Syntax
HRESULT get_Top( long *pTop );
Parameters
- pTop
- [out] Pointer to the y-axis origin to be retrieved.
Return Value
Returns an HRESULT value.
Retrieves the visibility of the video window.
Syntax
HRESULT get_Visible( long *pVisible );
Parameters
- pVisible
- [out] Pointer to a value indicating whether the window is shown. OATRUE if it is; otherwise, the window is hidden.
Return Value
Returns an HRESULT value.
Retrieves the width of the video window.
Syntax
HRESULT get_Width( long *pWidth );
Parameters
- pWidth
- [out] Pointer to the width to be retrieved.
Return Value
Returns an HRESULT value.
Retrieves the current window rectangle (not the client rectangle), in device coordinates.
Syntax
HRESULT GetWindowPosition( long *pLeft, long *pTop, long *pWidth, long *pHeight );
Parameters
- pLeft
- [out] Pointer to the x-axis origin of the window.
- pTop
- [out] Pointer to the y-axis origin of the window.
- pWidth
- [out] Pointer to the width of the window, in pixels.
- pHeight
- [out] Pointer to the height of the window, in pixels.
Return Value
Returns an HRESULT value.
Remarks
This method has the same effect as individually calling the IVideoWindow::get_Left, IVideoWindow::get_Top, IVideoWindow::get_Width, and IVideoWindow::get_Height methods.
Returns the state of the video window.
Syntax
HRESULT get_WindowState( long *WindowState );
Parameters
- WindowState
- [out] Pointer to flags indicating the state of the video window.
Return Value
Returns an HRESULT value.
Remarks
This method retrieves a subset of the properties of the window state, specifically SW_MINIMIZE, SW_MAXIMIZE, SW_SHOW, or SW_HIDE. These have the same definitions as the Win32 ShowWindow function.
Changes the style parameters for the video window.
Syntax
HRESULT get_WindowStyle( long *pWindowStyle );
Parameters
- pWindowStyle
- [out] Pointer to a set of flags that matches a subset of the flags that can be set by the GWL_STYLE value of the Win32 GetWindowLong function.
Return Value
Returns an HRESULT value.
Remarks
For a complete list of window styles, see the CreateWindow function in the Platform Software Development Kit (SDK).
Changes the style parameters for the video window.
Syntax
HRESULT get_WindowStyleEx( long *pWindowStyleEx );
Parameters
- pWindowStyleEx
- [out, retval] Pointer to a set of flags that matches a subset of the flags that can be set by the GWL_STYLE value of the Win32 GetWindowLong function.
Return Value
Returns an HRESULT value.
Remarks
This method uses extended window styles. For a complete list of window styles, see the CreateWindow function in the Platform SDK.
Hides the cursor.
Syntax
HRESULT HideCursor( long HideCursor );
Parameters
- HideCursor
- [in] Value specifying whether to hide the cursor. If OATRUE, do not display the cursor; if OAFALSE, display the cursor.
Return Value
Returns an HRESULT value.
Remarks
This method is typically used when the video renderer is in full-screen mode, where cursor display might be unwanted.
Determines if the cursor is hidden or showing.
Syntax
HRESULT IsCursorHidden( long *CursorHidden );
Parameters
- CursorHidden
- [out] Pointer to a value indicating whether the cursor is hidden; if OATRUE, cursor is hidden; if OAFALSE, cursor is displayed.
Return Value
Returns an HRESULT value.
Remarks
This method is typically used when the video renderer is in full-screen mode, where cursor display might be unwanted.
Forwards messages that have been received by a parent window to a child window owned by a filter.
Syntax
HRESULT NotifyOwnerMessage( long hwnd, long uMsg, long wParam, long lParam );
Parameters
- hwnd
- [in] Window handle.
- uMsg
- [in] Message being sent.
- wParam
- [in] Message's wParam passed in.
- lParam
- [in] Message's lParam passed in.
Return Value
Returns an HRESULT value.
Remarks
This method should be used by windows that make a renderer window a child window. It forwards significant messages to the child window that the child window would not otherwise receive. This includes the following messages.
- WM_ACTIVATEAPP
- WM_DEVMODECHANGE
- WM_DISPLAYCHANGE
- WM_PALETTECHANGED
- WM_PALETTEISCHANGING
- WM_QUERYNEWPALETTE
- WM_SYSCOLORCHANGE
Determines whether the window will be automatically shown.
Syntax
HRESULT put_AutoShow( long AutoShow );
Parameters
- AutoShow
- [in] Value specifying whether the window will be automatically shown. OATRUE (1) means the window will be visible when the state changes; OAFALSE (0) means the window remains hidden until explicitly shown.
Return Value
Returns an HRESULT value.
Remarks
Many simple applications require a displayed window when a filter graph is set to the running state. AutoShow defaults to OATRUE so that when the graph changes state to paused or running, the window is visible (it also is set as the foreground window). It will remain visible on all subsequent state changes to paused or running. If you close the window while the stream is running, the window will not automatically reappear. If you stop and restart the stream, however, the window will automatically reappear.
See Also
Determines whether any palette required will be realized in the background.
Syntax
HRESULT put_BackgroundPalette( long BackgroundPalette );
Parameters
- BackgroundPalette
- [in] Value specifying whether the palette will be realized in the background. Set to OATRUE (1) to realize the palette in the background; otherwise, set to OAFALSE.
Return Value
Returns an HRESULT value.
Remarks
If BackgroundPalette is OATRUE, any palette required by the video is realized by the renderer in the background. This means that any colors the palette uses will change to their closest match in the display palette prior to drawing. This ensures that an application will not have its palette disturbed when playing a video. It does, however, impose severe performance penalties on the video and should not be used unless absolutely necessary. The default value for this property is OAFALSE.
Sets the border color for the video window.
Syntax
HRESULT put_BorderColor( long Color );
Parameters
- Color
- [in] New border color as a COLORREF type.
Return Value
Returns an HRESULT value.
Remarks
When a destination rectangle that is set differs from the visible client area of the window, a border is exposed around the edge. This method allows an application to change the border color. It is set to black by default. Any nonsystem color passed in is converted to its closest match according to the current palette before being used (this is not an issue on true color devices). Setting this causes the window border to be repainted in the new color automatically.
Sets the textual title string for the video window.
Syntax
HRESULT put_Caption( BSTR strCaption );
Parameters
- strCaption
- [in] Window title caption.
Return Value
Returns an HRESULT value.
Sets the full-screen mode for the video renderer filter supporting this interface.
Syntax
HRESULT put_FullScreenMode( long FullScreenMode );
Parameters
- FullScreenMode
- [in] Value specifying whether the video renderer filter supports full-screen mode; set to OATRUE if supporting full-screen video, or OAFALSE if not.
Return Value
Returns E_NOTIMPL if the video renderer doesn't support full-screen mode or NOERROR if it does.
Remarks
This method enables an application to switch a full-screen renderer into and out of full-screen mode. The renderer's behavior when switched out of full-screen mode is implementation-dependent. The Microsoft full-screen renderer, for example, switches back to a window.
The IVideoWindow plug-in distributor in the filter graph manager implements full-screen renderer switching. It looks to see if any renderer in the graph supports a full-screen mode and, if not, will temporarily replace the renderer with the default DirectShow full-screen renderer. It calls IVideoWindow::GetMaxIdealImageSize to determine if a window can be made a topmost window and resized to the entire display. This is preferred to swapping renderers, because the filter graph might be using DirectDraw® overlays or a hardware decoder filter.
Sets the height of the video window.
Syntax
HRESULT put_Height( long Height );
Parameters
- Height
- [in] New vertical dimension of the video window.
Return Value
Returns an HRESULT value.
Remarks
Calling this method does not affect the y-axis coordinate of the video window.
Sets the x-axis coordinate for the video window.
Syntax
HRESULT put_Left( long Left );
Parameters
- Left
- [in] The x-axis coordinate to be set.
Return Value
Returns an HRESULT value.
Remarks
Calling this method does not affect the video window's width.
Specifies a window to which the video window will post messages.
Syntax
HRESULT put_MessageDrain( OAHWND Drain );
Parameters
- Drain
- [in] Window to which messages will be posted.
Return Value
Returns an HRESULT value.
Remarks
The video renderer passes messages to the specified message drain by calling the Win32 PostMessage function. These messages allow you to write applications that include user interaction, such as applications that require mouse clicks on specific areas of the video display. An application can have a close relationship with the video window and know at certain time points to look for user interaction. When the renderer passes a message to the drain, it sends the parameters, such as the client-area coordinates, exactly as generated.
DirectShow passes the following messages to the window specified by the Drain parameter, if and when the application generates them.
- WM_KEYDOWN
- WM_KEYUP
- WM_LBUTTONDBLCLK
- WM_LBUTTONDOWN
- WM_LBUTTONUP
- WM_MBUTTONDBLCLK
- WM_MBUTTONDOWN
- WM_MBUTTONUP
- WM_MOUSEACTIVATE
- WM_MOUSEMOVE
- WM_NCLBUTTONDBLCLK
- WM_NCLBUTTONDOWN
- WM_NCLBUTTONUP
- WM_NCMBUTTONDBLCLK
- WM_NCMBUTTONDOWN
- WM_NCMBUTTONUP
- WM_NCMOUSEMOVE
- WM_NCRBUTTONDBLCLK
- WM_NCRBUTTONDOWN
- WM_NCRBUTTONUP
- WM_RBUTTONDBLCLK
- WM_RBUTTONDOWN
- WM_RBUTTONUP
Because this member function does not make the message drain window a child window, applications with full-screen capabilities can use it.
Sets an owning parent for the video window.
Syntax
HRESULT put_Owner( OAHWND Owner );
Parameters
- Owner
- [in] Handle of new owner window.
Return Value
Returns an HRESULT value.
Remarks
This method offers a way for applications to set the owner of the video window. This is often used when playing videos in compound documents. This method changes the parent of the renderer window and sets the WS_CHILD style for the video window.
To forward video window messages to the parent window, use the IVideoWindow::put_MessageDrain method, supplying the window handle of the parent window. This method does not post messages automatically.
After using this method to set the owner of a video window, you must reset the owner to NULL (by calling put_Owner(NULL)) before releasing the filter graph. Otherwise, messages will continue to be sent to this window and errors will likely occur when the application is terminated.
Sets the y-axis coordinate of the video window.
Syntax
HRESULT put_Top( long Top );
Parameters
- Top
- [in] The y-axis origin of the video window.
Return Value
Returns an HRESULT value.
Remarks
Calling this method does not affect the height of the video window.
Changes the visibility of the video window.
Syntax
HRESULT put_Visible( long Visible );
Parameters
- Visible
- [in] Boolean flag that is compatible with Automation.
Return Value
Returns an HRESULT value.
Remarks
If the Visible parameter is set to OATRUE (1), the window is shown. If it is set to OAFALSE (0), the window is hidden.
Sets the video window's width.
Syntax
HRESULT put_Width( long Width );
Parameters
- Width
- [in] Width to be set, in pixels.
Return Value
Returns an HRESULT value.
Remarks
Calling this method does not affect the video window's x-axis coordinate.
Sets the video window's state.
Syntax
HRESULT put_WindowState( long WindowState );
Parameters
- WindowState
- [in] Describes the video window's state.
Return Value
Returns NOERROR.
Remarks
This method is a wrapper for the Microsoft Win32 ShowWindow function. IVideoWindow::put_WindowState passes the WindowState parameter on to CBaseWindow::DoShowWindow, which in turn passes it on to ShowWindow. Hence, WindowState can be any value that is valid for ShowWindow.
Changes the style parameters for the video window.
Syntax
HRESULT put_WindowStyle( long WindowStyle );
Parameters
- WindowStyle
- [in] Set of flags that matches a subset of the flags that can be set by the GWL_STYLE value of the Microsoft Win32 GetWindowLong function.
Return Value
Returns an HRESULT value.
Remarks
Use this property to change the overall style of the video window; for example, to remove the border and caption areas of the video window. It is a fairly thin wrapper on top of setting the GWL_STYLE value of the Microsoft Win32 GetWindowLong function and therefore must be treated with care. In particular, ensure that the current styles are first retrieved, and then the necessary bit fields are added or removed. With some exceptions (noted here), the acceptable flags are the same as those allowed by the Win32 CreateWindow function.
Do not use this method to affect the window size. For example, if the window is minimized, do not set the WS_MAXIMIZE style; doing so causes unpredictable results. Instead, use the IVideoWindow::put_WindowState method for maximizing or minimizing the window.
Any of the following styles return E_INVALIDARG.
- WS_DISABLED
- WS_HSCROLL
- WS_ICONIC
- WS_MAXIMIZE
- WS_MINIMIZE
- WS_VSCROLL
Sets the style of the control window.
Syntax
HRESULT put_WindowStyleEx( long WindowStyleEx );
Parameters
- WindowStyleEx
- [in] Value that specifies the style of the control window.
Return Value
Returns NOERROR.
Remarks
This method uses EX window styles. For a complete list of extended window styles, see the CreateWindowEx function in the Platform SDK.
Use this property to change the overall style of the video window; for example, to remove the border and caption areas of the video window. It is a fairly thin wrapper on top of setting the GWL_STYLE value of the Microsoft Win32 GetWindowLong function and therefore must be treated with care. In particular, ensure that the current styles are first retrieved, and then the necessary bit fields are added or removed.
Do not use the following window styles because they are not validated.
- WS_DISABLED
- WS_HSCROLL
- WS_ICONIC
- WS_MAXIMIZE
- WS_MINIMIZE
- WS_VSCROLL
With some exceptions (noted here), the acceptable flags are the same as those allowed by the Win32 CreateWindow function.
Moves the video window to the foreground and optionally gives it focus.
Syntax
HRESULT SetWindowForeground( long Focus );
Parameters
- Focus
- Value that specifies whether the video window will get focus. A value of 1 gives the window focus and 0 does not.
Return Value
Returns one of the following values.
NOERROR The method succeeded. E_INVALIDARG Focus doesn't equal 1 or 0. VFW_E_NOT_CONNECTED The current filter isn't connected to a complete filter graph.
Sets the position of the video window (not the client rectangle position) in device coordinates.
Syntax
HRESULT SetWindowPosition( long Left, long Top, long Width, long Height );
Parameters
- Left
- [in] The x-axis origin of the window.
- Top
- [in] The y-axis origin of the window.
- Width
- [in] Width of the window, in pixels.
- Height
- [in] Height of the window, in pixels.
Return Value
Returns an HRESULT value.
Remarks
This method has the same effect as individually calling the IVideoWindow::put_Left, IVideoWindow::put_Top, IVideoWindow::put_Width, and IVideoWindow::put_Height methods.
Specify, in window coordinates, where the video should appear. For example, setting a destination of (100,50,200,400) positions the video playback at an origin of 100 pixels from the left of the client area and 50 pixels from the top, with an overall size of 200 × 400 pixels. If the video is smaller than this (or a source rectangle has been specified that is smaller than the video), it will be stretched appropriately. Similarly, if the video is larger than the destination rectangle, the video is compressed into the visible rectangle. There are fairly severe performance penalties if an application does not keep the source and destination rectangles the same size.
Under typical circumstances, when no destination rectangle has been set, the video fills the entire visible client window area (regardless of how much the user has stretched the window). Also, the destination rectangle properties correctly return the size of the video window client area.
Top of Page
© 2000 Microsoft and/or its suppliers. All rights reserved. Terms of Use.