The CBaseWindow class creates a window and a worker thread. The worker thread pulls messages from the window's input queue and dispatches them as appropriate. The window and its thread are created by the CBaseWindow::PrepareWindow member function and destroyed by the CBaseWindow::DoneWithWindow member function. The window should also be initialized by the CBaseWindow::InitialiseWindow member function and uninitialized by the CBaseWindow::UninitialiseWindow member function. After preparing and initializing a window, size it by using the CBaseWindow::ActivateWindow member function; hide the window using the CBaseWindow::InactivateWindow member function.
Protected Data Members
Name | Description |
m_bActivated | Flag to indicate window activation status. |
m_bBackground | Flag to indicate if palettes are to be realized in the background. |
m_ClassStyles | Class styles for the window. |
m_hdc | Device context (DC) for the window. |
m_Height | Client window height. |
m_hInstance | Global module instance handle. |
m_hPalette | Handle to a palette belonging to this object. |
m_hwnd | Handle for this object's window. |
m_MemoryDC | Memory DC used for fast bit-block transfer operations. |
m_pClassName | Static string holding the class name. |
m_RealizePalette | Message sent to indicate the window palette has changed. |
m_ShowStageMessage | Message sent by IVideoWindow::SetWindowForeground that moves the current window to the foreground and optionally gives it focus. |
m_ShowStageTop | Message sent to set the window to WS_EX_TOPMOST style. |
m_SyncWorker | CAMEvent data member used to provide interthread synchronization. |
m_SyncWorkerCreate | CAMMsgEvent data member used to signal the constructor for the window class when to create the window. |
m_hThread | Worker thread for the window. |
m_ThreadSignal | Data member used by the thread to signal errors. |
m_Width | Client window width. |
m_WindowLock | Data member used to serialize window object access. |
m_WindowStyles | Data member used to serialize the initial window styles. |
m_WindowStylesEx | Data member used to serialize the initial extended window styles. |
Member Functions
Name | Description |
CBaseWindow | Constructs a CBaseWindow object. |
DoSetWindowForeground | Brings the window to the foreground. |
DoShowWindow | Sets the show state of the specified window. |
GetMemoryHDC | Retrieves the default offscreen memory device context (DC). |
GetWindowHDC | Retrieves the default main window DC. |
GetWindowHeight | Retrieves the current window height. |
GetWindowHWND | Retrieves the window handle for the window. |
GetWindowWidth | Retrieves the current window width. |
PerformanceAlignWindow | Aligns the window to a DWORD boundary for maximum performance. |
PaintWindow | Invalidates the window client area. |
Overridable Member Functions
Name | Description |
ActivateWindow | Sizes the window according to the requirements of the derived class. |
DoneWithWindow | Closes, deletes, and frees the window resources. |
DoRealisePalette | Selects and realizes the current palette in the window. |
GetClassWindowStyles | Returns class and window information. |
GetDefaultRect | Returns the default size for the window. |
InactivateWindow | Hides the window. |
InitialiseWindow | Creates the default device contexts. |
MessageLoop | Implements a window message loop. |
OnClose | Handles the WM_CLOSE message for the base class. |
OnPaletteChange | Handles WM_PALETTEISCHANGING and WM_PALETTECHANGED messages. |
OnSize | Handles WM_SIZE messages for the base class. |
OnReceiveMessage | Indicates a base class implementation of a window procedure. |
PrepareWindow | Initializes the window along with a worker thread. |
SetPalette | Changes the palette that the window should realize. |
UninitialiseWindow | Destroys the device contexts created for the window. |
Sizes the window according to the requirements of the derived class.
virtual HRESULT ActivateWindow( );
Returns an HRESULT value.
This member function calls CBaseWindow::GetDefaultRect, which a derived class should override to return the size of the images that will be displayed. ActivateWindow then sizes the window so that the client area matches this size.
Constructs a CBaseWindow object.
CBaseWindow(
BOOL bDoGetDC = TRUE
);
No return value.
The window and its worker thread are created by CBaseWindow::PrepareWindow and destroyed by CBaseWindow::DoneWithWindow.
Destroys the window and its worker thread.
virtual HRESULT DoneWithWindow( );
Returns an HRESULT value.
The base window class creates a window and a worker thread. The worker thread is responsible for pulling messages from the window's input queue and dispatching them as appropriate. The window and its thread are created by CBaseWindow::PrepareWindow and destroyed by CBaseWindow::DoneWithWindow. The window should also be initialized using CBaseWindow::InitialiseWindow and uninitialized using CBaseWindow::UninitialiseWindow. Having prepared a window and initialized it, the window can be sized using CBaseWindow::ActivateWindow and subsequently hidden using CBaseWindow::InactivateWindow.
Realizes any palette provided to the window.
virtual HRESULT DoRealisePalette(
BOOL bForceBackground
);
Returns an HRESULT value.
The window class is given a palette handle to use with the CBaseWindow::SetPalette member function. Once a palette has been installed, it can be realized by calling this member function. The class will also call this member function when it gets WM_QUERYNEWPALETTE and WM_PALETTECHANGED messages from the Microsoft® Windows® operating system.
Call this method with TRUE in response to WM_SETPALETTE and FALSE in response to WM_QUERNEWPALETTE.
Sets the video window to the foreground and optionally gives it focus.
void DoSetWindowForeground(
BOOL bFocus
);
No return value.
DirectShow provides this method to make it easy for applications to move video windows to the foreground; normally, it is programatically complex for a thread associated with one window to affect a window associated with a different thread. This method passes the WM_SHOWWINDOW message to the video window's renderer, so the application's window procedure must handle this message and bring the appropriate window to the foreground and give it focus, if specified.
Sets the show state of the specified window.
HRESULT DoShowWindow(
LONG ShowCmd
);
Returns an HRESULT value.
This member function simply calls the Microsoft Win32® ShowWindow function.
Returns class and window information.
virtual LPTSTR GetClassWindowStyles(
DWORD *pClassStyles,
DWORD *pWindowStyles,
DWORD *pWindowStylesEx
) PURE;
Returns a class name that is a static text string.
A derived class must override this pure virtual member function to provide the default class and window styles for the window. The information the derived class returns is used in CBaseWindow::PrepareWindow when the window is first created. The class and window styles take the same parameters as their counterparts in the Microsoft Win32 CreateWindowEx function. The string that is returned should be allocated as a static string and should still be valid after the member function returns.
Retrieves the default size for the window client area.
virtual RECT GetDefaultRect( );
Returns the default rectangle.
When the window is activated, it calls this member function to determine how large it should make the window's client area. A video renderer will typically return the size of the native video image.
Retrieves the default memory device context (DC).
virtual HDC GetMemoryHDC( );
Returns the default memory DC.
The base window class creates a window with a worker thread when it is prepared (in CBaseWindow::PrepareWindow). It also creates two DCs that can be used for drawing. The first is a normal window handle to a device context (HDC); the second is an offscreen HDC that can be used as a source HDC in bit-block transfer functions.
Retrieves the default window device context (DC).
HDC GetWindowHDC( );
Returns the default window DC.
The base window class creates a window with a worker thread when it is prepared (in CBaseWindow::PrepareWindow). It also creates two DCs that can be used for drawing. The first is a normal window handle to a device context (HDC); the second is an offscreen HDC that can be used as a source HDC in bit-block transfer functions.
Retrieves the current window height.
LONG GetWindowHeight( );
Returns the window height in pixels.
This member function is updated when the base class receives WM_SIZE messages.
Retrieves the window handle associated with this object.
HWND GetWindowHWND( );
Returns a window handle.
If called before issuing a CBaseWindow::PrepareWindow call, this member function returns NULL.
Retrieves the current window width.
LONG GetWindowWidth( );
Returns the window width in pixels.
This member function is updated when the base class receives WM_SIZE messages.
Effectively hides the window (if it was visible).
virtual HRESULT InactivateWindow( );
Returns an HRESULT value.
The base window class creates a window and a worker thread. The worker thread is responsible for pulling messages from the window's input queue and dispatching them as appropriate. The window and its thread are created by CBaseWindow::PrepareWindow and destroyed in CBaseWindow::DoneWithWindow. The window should be initialized through CBaseWindow::InitialiseWindow and uninitialized through CBaseWindow::UninitialiseWindow. Having prepared a window and initialized it, the window can be sized using CBaseWindow::ActivateWindow and subsequently hidden using CBaseWindow::InactivateWindow.
Creates default device contexts for the window.
virtual InitialiseWindow(
HWND hwnd
);
Returns an HRESULT value.
The base window class creates a window and a worker thread. The worker thread is responsible for pulling messages from the window's input queue and dispatching them as appropriate. The window and its thread are created by CBaseWindow::PrepareWindow and destroyed in CBaseWindow::DoneWithWindow. The window should be initialized through CBaseWindow::InitialiseWindow and uninitialized through CBaseWindow::UninitialiseWindow. Having prepared a window and initialized it, the window can be sized using CBaseWindow::ActivateWindow and subsequently hidden using CBaseWindow::InactivateWindow.
The base class creates two device contexts that can be used for drawing. The first is a standard handle to a device context (HDC) for the window; the second is an offscreen HDC. The offscreen HDC often is useful for selecting bitmaps before calling the Microsoft Win32 BitBlt or StretchBlt function to copy the bitmap to the main window. This member function also sets the default stretch mode to be COLORONCOLOR. The member function is virtual so that derived classes can change this default if desired.
Implements a window message loop.
virtual HRESULT MessageLoop( );
Returns an HRESULT value.
Any application that creates a window must have a message loop that retrieves and dispatches messages from the window's input queue. After retrieving a message, this member function calls the CBaseWindow::OnReceiveMessage member function that belongs to the object. The CBaseWindow::MessageLoop member function is a virtual member function so that derived classes can do more complex handling of messages in the loop.
Handles the WM_CLOSE message.
virtual BOOL OnClose( );
No return value.
The default behavior for this member function is to simply hide the window. A derived class should not destroy the window when it receives a WM_CLOSE message but should send an EC_USERABORT notification to the filter graph manager. This will have the playback stopped, and in some cases will also have the filters disconnected and released. It is only when the filter that owns the window is finally released (that is, destroyed) that the derived class should actually destroy the window (using CBaseWindow::DoneWithWindow).
Handles WM_PALETTEISCHANGING and WM_PALETTECHANGED messages.
virtual LRESULT OnPaletteChange(
HWND hwnd,
UINT Message
);
Returns one of the following values.
Value | Meaning |
0 | Message was not handled. |
1 | Message was processed. |
When the base class receives a WM_PALETTEISCHANGING message, it realizes its palette again. It must also do this when told, through WM_PALETTECHANGED, that the system palette has changed. In the latter case, however, the base class must be careful not to realize its palette if it was the window that caused the WM_PALETTECHANGED message (which is why the window that caused the message to be sent is passed into the member function).
This is a protected member function.
Indicates a base class implementation of a window procedure.
virtual LRESULT OnReceiveMessage(
HWND hwnd,
INT uMsg,
WPARAM wParam,
LPARAM lParam
);
Returns an LRESULT value, based on the uMsg parameter. If uMsg is not one of the specified values, OnReceiveMessage passes the message to the Win32 DefWindowProc function and forwards the resulting return value to the caller.
Message | Action |
m_RealizePalette | Returns 0 |
m_ShowStageMessage | Returns 1 |
m_ShowStageTop | Returns 1 |
WM_CLOSE | Returns 0 |
WM_PALETTECHANGED | Returns 0 |
WM_QUERYNEWPALETTE | Returns result of CBaseWindow::OnPaletteChange |
WM_SIZE | Returns 0 |
WM_SYSCOLORCHANGE | Returns 1 |
Handles the WM_SIZE message.
virtual BOOL OnSize(
LONG Width,
LONG Height
);
No return value.
This member function stores the window width and height so that they can be returned from the CBaseWindow::GetWindowHeight and CBaseWindow::GetWindowWidth member functions.
Invalidates the window client area.
void PaintWindow(
BOOL bErase
);
No return value.
Aligns the window to a DWORD boundary for maximum performance.
HRESULT PerformanceAlignWindow( );
Returns an HRESULT value.
This member function can be called, if the video is not owned by another window, to align the left edge and the top of the window for best display performance.
Creates a window and a worker thread.
virtual HRESULT PrepareWindow( );
Returns an HRESULT value.
The base window class creates a window and a worker thread. The worker thread is responsible for pulling messages from the window's input queue and dispatching them as appropriate. The window and its thread are created by CBaseWindow::PrepareWindow and destroyed in CBaseWindow::DoneWithWindow. The window should also be initialized and uninitialized through CBaseWindow::InitialiseWindow and CBaseWindow::UninitialiseWindow, respectively. Having prepared a window and initialized it, the window can be sized using CBaseWindow::ActivateWindow and subsequently hidden using CBaseWindow::InactivateWindow.
Sets a palette for the window to use.
virtual HRESULT SetPalette(
HPALETTE hPalette
);
Returns an HRESULT value.
This member function allows a filter to install a palette in the window object. The palette handle passed in should be non-NULL. The palette is realized when it is installed. The window object does not delete any previous palette that it was using; the client using the window object should ensure it deletes the palette it creates at the appropriate time.
Flushes GDI and deletes the default device contexts.
virtual UninitialiseWindow( );
Returns an HRESULT value.
The base window class creates a window and a worker thread. The worker thread is responsible for pulling messages from the window's input queue and dispatching them as appropriate. The window and its thread are created by CBaseWindow::PrepareWindow and destroyed in CBaseWindow::DoneWithWindow. The window should also be initialized and uninitialized through CBaseWindow::InitialiseWindow and CBaseWindow::UninitialiseWindow, respectively. Having prepared a window and initialized it, the window can be sized using CBaseWindow::ActivateWindow and subsequently hidden using CBaseWindow::InactivateWindow.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.