CODWndComponent Class

class CODWndComponent: public CODPropertyNotifySink

This class serves as a base class for windowed components. A windowed component encapsulates a window as a component. Each windowed component contains a window handle. This class defines the virtual function  CreateWnd for creating the window associated with the component. Derived classes override CreateWnd and create a specific type of window.

Windowed components draw themselves in response to WM_PAINT messages, like any other window. The virtual OnDraw method is used to position the window and make it visible or invisible. The window takes care of drawing itself.

Any type of window can used as a windowed component. Examples are list boxes, buttons, edit controls, and ActiveX controls.

This class contains a number of functions that are simple wrappers around Windows API functions that take a window handle. For complete documentation on the wrapper functions, consult the Windows API documentation.

Defined in: OdWndComp.h

Class Members

 CODWndComponent()

Constructor.

 CODWndComponent(const CODWndComponent& src)

Copy constructor.

virtual  ~CODWndComponent()

Destructor.

HWND m_hWnd

Window handle.

CRect m_rcLocal

Local bounding rectangle for component.

virtual BOOL  Create(const CRect& rcLocal)

Creates the window component.

virtual BOOL  CreateWnd(HWND hParent)

Creates and returns a window object to caller.

virtual BOOL  DestroyWnd()

Destroys the window associated with this component

HWND  GetWnd() const

Return a pointer to the window.

virtual BOOL  IsChild(HWND hWnd) const

Determine if specified hwnd is a child or direct descendant of this component.

virtual BOOL  SetFocus()

Set input focus to this component.

void  SetLocalBounds(const CRect& rcLocal)

Set the local bounds of the component.

BOOL  IsHidden() const

Returns the value of the hidden flag.

void  SetHidden(const BOOL bHidden)

Sets the value of the hidden flag.

virtual CODRgn  GetEdgeRgn()

Returns a region surrounding the edges of the component.

virtual void  CalculateRgn(CODRgn* pRgn)

Calculates the bounding rectangle of the component.

CODWndComponent&  operator=(const CODWndComponent& src)

Assignment operator.

virtual CODComponent*  Dup() const

Creates a copy of this component.

virtual void  OnDraw(CDC* pDC)

Positions and shows the window.

virtual void  OnAmbientPropertyChange(const int nPropId)

Called when an ambient property is changed.

virtual void  Serialize(CArchive& ar)

Serializes the window component.

operator HWND() const

Cast component to window handle.

inline DWORD GetStyle() const

Get style flags.

inline DWORD GetExStyle() const

Get extended style flags.

inline LONG GetWindowLong(int nIndex) const

Get LONG data item associated with window.

inline LONG SetWindowLong(int nIndex, LONG dwNewLong)

Set LONG data item associated with window.

inline WORD GetWindowWord(int nIndex) const

Get WORD data item associated with window.

inline WORD SetWindowWord(int nIndex, WORD wNewWord)

Set WORD data item associated with window.

inline LRESULT SendMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)

Send a message to the window.

inline BOOL PostMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)

Post a message to the window.

inline BOOL SendNotifyMessage(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)

Send notification message to the window.

inline BOOL SetWindowText(LPCTSTR lpszString)

Set text associated with window.

inline int GetWindowText(LPTSTR lpszStringBuf, int nMaxCount) const

Get text associated with window.

inline int GetWindowTextLength() const

Get length of text associated with window.

inline void SetFont(HFONT hFont, BOOL bRedraw = TRUE)

Set the font associated with the window.

inline HFONT GetFont() const

Get the font associated with the window.

inline HMENU GetMenu() const

Get the menu associated with the window.

inline BOOL SetMenu(HMENU hMenu)

Set the menu associated with the window.

inline BOOL MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE)

Position the window.

inline BOOL MoveWindow(LPCRECT lpRect, BOOL bRepaint = TRUE)

Position the window.

inline BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)

Position the window.

inline BOOL SetWindowPos(HWND hWndInsertAfter, LPCRECT lpRect, UINT nFlags)

Position the window.

inline BOOL GetWindowRect(LPRECT lpRect) const

Get bounding rectangle of window.

inline BOOL GetClientRect(LPRECT lpRect) const

Get bounding rectangle of client area.

inline BOOL ClientToScreen(LPPOINT lpPoint) const

Convert point from client to screen coordinates.

inline BOOL ClientToScreen(LPRECT lpRect) const

Convert rectangle from client to screen coordinates.

inline BOOL ScreenToClient(LPPOINT lpPoint) const

Convert point from screen to client coordinates.

inline BOOL ScreenToClient(LPRECT lpRect) const

Convert rectangle from screen to client coordinates.

inline HDC GetDC()

Get a DC.

inline HDC GetWindowDC()

Get a window DC.

inline int ReleaseDC(HDC hDC)

Release a DC.

inline BOOL UpdateWindow()

Force a window update.

inline void SetRedraw(BOOL bRedraw = TRUE)

Set redraw.

inline BOOL GetUpdateRect(LPRECT lpRect, BOOL bErase = FALSE)

Get current update rectangle.

inline int GetUpdateRgn(HRGN hRgn, BOOL bErase = FALSE)

Get current update region.

inline BOOL Invalidate(BOOL bErase = TRUE)

Invalidate the window.

inline BOOL InvalidateRect(LPCRECT lpRect, BOOL bErase = TRUE)

Invalidate a rectangle.

inline BOOL ValidateRect(LPCRECT lpRect)

Validate a rectangle.

inline void InvalidateRgn(HRGN hRgn, BOOL bErase = TRUE)

Invalidate a region.

inline BOOL ValidateRgn(HRGN hRgn)

Validate a region.

inline BOOL ShowWindow(int nCmdShow)

Make the window visible.

inline BOOL IsWindowVisible() const

Determine if window is visible.

inline BOOL RedrawWindow(LPCRECT lpRectUpdate = NULL, HRGN hRgnUpdate = NULL, UINT flags = RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE)

Force the window to redraw.

inline BOOL IsWindowEnabled() const

Determine if window is enabled.

inline BOOL EnableWindow(BOOL bEnable = TRUE)

Enable the window.