CWindow

class CWindow

CWindow provides the base functionality for manipulating a window in ATL. Many of the CWindow methods simply wrap one of the Win32 API functions. For example, compare the prototypes for CWindow::ShowWindow and ::ShowWindow:

CWindow methodWin32 function
BOOL ShowWindow( int nCmdShow );BOOL ShowWindow( HWND hWnd, int nCmdShow );

CWindow::ShowWindow calls the Win32 function ShowWindow by passing CWindow::m_hWnd as the first parameter. Every CWindow method that directly wraps a Win32 function passes the m_hWnd member; therefore, much of the CWindow documentation will refer you to the Win32 SDK documentation.

Note Not every window-related Win32 function is wrapped by CWindow, and not every CWindow method wraps a Win32 function.

CWindow::m_hWnd stores the HWND that identifies a window. An HWND is attached to your object when you:

For more information about windows, see "Windows" and subsequent topics in the Win32 SDK. For more information about using windows in ATL, see the article ATL Window Classes.

#include <atlwin.h>


CWindow Class Members

Alert MethodsIcon Methods
Attribute MethodsMenu Methods
Caret MethodsMessage Methods
Clipboard MethodsScrolling Methods
Construction, Destruction, and InitializationTimer Methods
Coordinate Mapping MethodsUpdate and Painting Methods
Dialog Box Item MethodsWindow Access Methods
Drag-Drop MethodsWindow Size and Position Methods
Font MethodsWindow State Methods
Help MethodsWindow Text Methods
Hot Key MethodsWindow Tree Access Methods
Operators
Data Members
Alert Methods
FlashWindowFlashes the window once.
MessageBoxDisplays a message box.
Attribute Methods
GetExStyleRetrieves the extended window styles.
GetStyleRetrieves the window styles.
GetWindowLongRetrieves a 32-bit value at a specified offset into the extra window memory.
GetWindowWordRetrieves a 16-bit value at a specified offset into the extra window memory.
ModifyStyleModifies the window styles.
ModifyStyleExModifies the extended window styles.
SetWindowLongSets a 32-bit value at a specified offset into the extra window memory.
SetWindowWordSets a 16-bit value at a specified offset into the extra window memory.
Caret Methods
CreateCaretCreates a new shape for the system caret.
CreateGrayCaretCreates a gray rectangle for the system caret.
CreateSolidCaretCreates a solid rectangle for the system caret.
HideCaretHides the system caret.
ShowCaretDisplays the system caret.
Clipboard Methods
ChangeClipboardChainRemoves the window from the chain of Clipboard viewers.
OpenClipboardOpens the Clipboard.
SetClipboardViewerAdds the window to the Clipboard viewer chain.
Construction, Destruction, and Initialization
AttachAttaches a window to the CWindow object.
CWindowConstructor.
DestroyWindowDestroys the window associated with the CWindow object.
DetachDetaches the window from the CWindow object.
Coordinate Mapping Methods
ClientToScreenConverts client coordinates to screen coordinates.
MapWindowPointsConverts a set of points from the window's coordinate space to the coordinate space of another window.
ScreenToClientConverts screen coordinates to client coordinates.
Dialog Box Item Methods
CheckDlgButtonChanges the check state of the specified button.
CheckRadioButtonChecks the specified radio button.
DlgDirListFills a list box with the names of all files matching a specified path or filename.
DlgDirListComboBoxFills a combo box with the names of all files matching a specified path or filename.
DlgDirSelectRetrieves the current selection from a list box.
DlgDirSelectComboBoxRetrieves the current selection from a combo box.
GetDlgItemIntTranslates a control's text to an integer.
GetDlgItemTextRetrieves a control's text.
GetNextDlgGroupItemRetrieves the previous or next control within a group of controls.
GetNextDlgTabItemRetrieves the previous or next control having the WS_TABSTOP style.
IsDlgButtonCheckedDetermines the check state of the button.
SendDlgItemMessageSends a message to a control.
SetDlgItemIntChanges a control's text to the string representation of an integer value.
SetDlgItemTextChanges a control's text.
Drag-Drop Methods
DragAcceptFilesRegisters whether the window accepts dragged files.
Font Methods
GetFontRetrieves the window's current font.
SetFontChanges the window's current font.
Help Methods
GetWindowContextHelpIdRetrieves the window's help context identifier.
SetWindowContextHelpIdSets the window's help context identifier.
WinHelpStarts Windows Help.
Hot Key Methods
GetHotKeyDetermines the hot key associated with the window.
SetHotKeyAssociates a hot key with the window.
Icon Methods
GetIconRetrieves the window's large or small icon.
SetIconChanges the window's large or small icon.
Menu Methods
DrawMenuBarRedraws the window's menu bar.
GetMenuRetrieves the window's menu.
GetSystemMenuCreates a copy of the system menu for modification.
HiliteMenuItemHighlights or removes the highlight from a top-level menu item.
SetMenuChanges the window's current menu.
Message Methods
PostMessagePlaces a message in the message queue associated with the thread that created the window. Returns without waiting for the thread to process the message.
SendMessageSends a message to the window and does not return until the window procedure has processed the message.
SendNotifyMessageSends a message to the window. If the window was created by the calling thread, SendNotifyMessage does not return until the window procedure has processed the message. Otherwise, it returns immediately.
Scrolling Methods
EnableScrollBarEnables or disables the scroll bar arrows.
GetScrollPosRetrieves the position of the scroll box.
GetScrollRangeRetrieves the scroll bar range.
ScrollWindowScrolls the specified client area.
ScrollWindowExScrolls the specified client area with additional features.
SetScrollPosChanges the position of the scroll box.
SetScrollRangeChanges the scroll bar range.
ShowScrollBarShows or hides a scroll bar.
Timer Methods
KillTimerDestroys a timer event.
SetTimerCreates a timer event.
Update and Painting Methods
BeginPaintPrepares the window for painting.
EndPaintMarks the end of painting.
GetDCRetrieves a device context for the client area.
GetDCExRetrieves a device context for the client area and allows clipping options.
GetUpdateRectRetrieves the coordinates of the smallest rectangle that completely encloses the update region.
GetUpdateRgnRetrieves the update region and copies it into a specified region.
GetWindowDCRetrieves a device context for the entire window.
InvalidateInvalidates the entire client area.
InvalidateRectInvalidates the client area within the specified rectangle.
InvalidateRgnInvalidates the client area within the specified region.
IsWindowVisibleDetermines the window's visibility state.
LockWindowUpdateDisables or enables drawing in the window.
PrintRequests that the window be drawn in a specified device context.
PrintClientRequests that the window's client area be drawn in a specified device context.
RedrawWindowUpdates a specified rectangle or region in the client area.
ReleaseDCReleases a device context.
SetRedrawSets or clears the redraw flag.
ShowOwnedPopupsShows or hides the pop-up windows owned by the window.
ShowWindowSets the window's show state.
UpdateWindowUpdates the client area.
ValidateRectValidates the client area within the specified rectangle.
ValidateRgnValidates the client area within the specified region.
Window Access Methods
ChildWindowFromPointRetrieves the child window containing the specified point.
ChildWindowFromPointExRetrieves a particular type of child window containing the specified point.
GetLastActivePopupRetrieves the most recently active pop-up window.
GetParentRetrieves the immediate parent window.
GetTopLevelParentRetrieves the top-level parent or owner window.
GetTopLevelWindowRetrieves the top-level owner window.
GetTopWindowRetrieves the top-level child window.
GetWindowRetrieves the specified window.
IsChildDetermines whether the specified window is a child window.
SetParentChanges the parent window.
Window Size and Position Methods
ArrangeIconicWindowsArranges all minimized child windows.
BringWindowToTopBrings the window to the top of the Z order.
CenterWindowCenters the window against a given window.
GetClientRectRetrieves the coordinates of the client area.
GetWindowPlacementRetrieves the show state and positions.
GetWindowRectRetrieves the window's bounding dimensions.
IsIconicDetermines whether the window is minimized.
IsZoomedDetermines whether the window is maximized.
MoveWindowChanges the window's size and position.
SetWindowPlacementSets the show state and positions.
SetWindowPosSets the size, position, and Z order.
Window State Methods
EnableWindowEnables or disables input.
IsWindowEnabledDetermines whether the window is enabled for input.
SetActiveWindowActivates the window.
SetCaptureSends all subsequent mouse input to the window.
SetFocusSets the input focus to the window.
Window Text Methods
GetWindowTextRetrieves the window's text.
GetWindowTextLengthRetrieves the length of the window's text.
SetWindowTextChanges the window's text.
Window Tree Access Methods
GetDescendantWindowRetrieves the specified descendant window.
GetDlgCtrlIDRetrieves the window's identifier (for child windows only).
GetDlgItemRetrieves the specified child window.
SendMessageToDescendantsSends a message to the specified descendant windows.
SetDlgCtrlIDChanges the window's identifier.
Operators
operator HWNDConverts the CWindow object to an HWND.
operator =Assigns an HWND to the CWindow object.
Data Members
m_hWndThe handle to the window associated with the CWindow object.

CWindow Overview


Methods


CWindow::ArrangeIconicWindows

UINT ArrangeIconicWindows( );

See ArrangeIconicWindows in the Win32 SDK.

Remarks

Arranges all minimized child windows.

CWindow Overview | Class Members


CWindow::Attach

void Attach( HWND hWndNew );

Parameters

hWndNew [in] The handle to a window.

Remarks

Attaches the window identified by hWndNew to the CWindow object.

CWindow Overview | Class Members

See Also CWindow::Detach


CWindow::BeginPaint

HDC BeginPaint( LPPAINTSTRUCT lpPaint );

See BeginPaint in the Win32 SDK.

Remarks

Prepares the window for painting.

CWindow Overview | Class Members

See Also CWindow::EndPaint


CWindow::BringWindowToTop

BOOL BringWindowToTop( );

See BringWindowToTop in the Win32 SDK.

Remarks

Brings the window to the top of the Z order.

CWindow Overview | Class Members

See Also CWindow::MoveWindow, CWindow::SetWindowPos


CWindow::CenterWindow

BOOL CenterWindow( HWND hWndCenter = NULL );

Return Value

TRUE if the window is successfully centered; otherwise, FALSE.

Parameters

hWndCenter [in] The handle to the window against which to center. If this parameter is NULL (the default value), the method will set hWndCenter to the window's parent window if it is a child window. Otherwise, it will set hWndCenter to the window's owner window.

Remarks

Centers the window against a given window.

CWindow Overview | Class Members

See Also CWindow::MoveWindow, CWindow::SetWindowPos


CWindow::ChangeClipboardChain

BOOL ChangeClipboardChain( HWND hWndNewNext );

See ChangeClipboardChain in the Win32 SDK.

Remarks

Removes the window from the chain of Clipboard viewers.

CWindow Overview | Class Members

See Also CWindow::SetClipboardViewer


CWindow::CheckDlgButton

BOOL CheckDlgButton( int nIDButton, UINT nCheck );

See CheckDlgButton in the Win32 SDK.

Remarks

Changes the check state of the specified button.

CWindow Overview | Class Members

See Also CWindow::CheckRadioButton, CWindow::IsDlgButtonChecked


CWindow::CheckRadioButton

BOOL CheckRadioButton( int nIDFirstButton, int nIDLastButton, int nIDCheckButton );

See CheckRadioButton in the Win32 SDK.

Remarks

Checks the specified radio button.

CWindow Overview | Class Members

See Also CWindow::CheckDlgButton


CWindow::ChildWindowFromPoint

HWND ChildWindowFromPoint( POINT point ) const;

See ChildWindowFromPoint in the Win32 SDK.

Remarks

Retrieves the child window containing the specified point.

CWindow Overview | Class Members

See Also CWindow::ChildWindowFromPointEx


CWindow::ChildWindowFromPointEx

HWND ChildWindowFromPoint( POINT point, UINT uFlags ) const;

See ChildWindowFromPointEx in the Win32 SDK.

Remarks

Retrieves a particular type of child window containing the specified point.

CWindow Overview | Class Members

See Also CWindow::ChildWindowFromPoint


CWindow::ClientToScreen

BOOL ClientToScreen( LPPOINT lpPoint ) const;
BOOL ClientToScreen( LPRECT lpRect ) const;

See ClientToScreen in the Win32 SDK.

Remarks

Converts client coordinates to screen coordinates. The second version of this method allows you to convert the coordinates of a RECT structure.

CWindow Overview | Class Members

See Also CWindow::ScreenToClient


CWindow::CreateCaret

BOOL CreateCaret( HBITMAP pBitmap );

See CreateCaret in the Win32 SDK.

Remarks

Creates a new shape for the system caret.

CWindow Overview | Class Members

See Also CWindow::CreateGrayCaret, CWindow::CreateSolidCaret


CWindow::CreateGrayCaret

BOOL CreateGrayCaret( int nWidth, int nHeight );

See CreateCaret in the Win32 SDK.

Remarks

Creates a gray rectangle for the system caret. Passes (HBITMAP) 1 for the bitmap handle parameter to the Win32 function.

CWindow Overview | Class Members

See Also CWindow::CreateCaret, CWindow::CreateSolidCaret


CWindow::CreateSolidCaret

BOOL CreateSolidCaret( int nWidth, int nHeight );

See CreateCaret in the Win32 SDK.

Remarks

Creates a solid rectangle for the system caret. Passes (HBITMAP) 0 for the bitmap handle parameter to the Win32 function.

CWindow Overview | Class Members

See Also CWindow::CreateCaret, CWindow::CreateGrayCaret


CWindow::CWindow

CWindow( HWND hWnd = NULL );

Parameters

hWnd [in] The handle to a window.

Remarks

The constructor. Initializes the m_hWnd member to hWnd, which by default is NULL.

Note CWindow::CWindow does not create a window. Classes CWindowImpl, CContainedWindow, and CDialogImpl (all of which derive from CWindow) provide a method to create a window or dialog box, which is then assigned to CWindow::m_hWnd. You can also use the CreateWindow Win32 function.

CWindow Overview | Class Members


CWindow::DestroyWindow

BOOL DestroyWindow( );

See DestroyWindow in the Win32 SDK.

Remarks

Destroys the window associated with the CWindow object and sets m_hWnd to NULL. It does not destroy the CWindow object itself.

CWindow Overview | Class Members


CWindow::Detach

HWND Detach( );

Return Value

The HWND associated with the CWindow object.

Remarks

Detaches m_hWnd from the CWindow object and sets m_hWnd to NULL.

CWindow Overview | Class Members

See Also CWindow::Attach


CWindow::DlgDirList

int DlgDirList( LPTSTR lpPathSpec, int nIDListBox, int nIDStaticPath, UINT nFileType );

See DlgDirList in the Win32 SDK.

Remarks

Fills a list box with the names of all files matching a specified path or filename.

CWindow Overview | Class Members

See Also CWindow::DlgDirListComboBox, CWindow::DlgDirSelect, CWindow::DlgDirSelectComboBox


CWindow::DlgDirListComboBox

int DlgDirListComboBox( LPTSTR lpPathSpec, int nIDComboBox, int nIDStaticPath, UINT nFileType );

See DlgDirListComboBox in the Win32 SDK.

Remarks

Fills a combo box with the names of all files matching a specified path or filename.

CWindow Overview | Class Members

See Also CWindow::DlgDirList, CWindow::DlgDirSelectt, CWindow::DlgDirSelectComboBox


CWindow::DlgDirSelect

BOOL DlgDirSelect( LPTSTR lpString, int nCount, int nIDListBox );

See DlgDirSelectEx in the Win32 SDK.

Remarks

Retrieves the current selection from a list box.

CWindow Overview | Class Members

See Also CWindow::DlgDirSelectComboBox, CWindow::DlgDirList


CWindow::DlgDirSelectComboBox

BOOL DlgDirSelectComboBox( LPTSTR lpString, int nCount, int nIDComboBox );

See DlgDirSelectComboBoxEx in the Win32 SDK.

Remarks

Retrieves the current selection from a combo box.

CWindow Overview | Class Members

See Also CWindow::DlgDirSelect, CWindow::DlgDirListComboBox


CWindow::DragAcceptFiles

void DragAcceptFiles( BOOL bAccept = TRUE );

See DragAcceptFiles in the Win32 SDK.

Remarks

Registers whether the window accepts dragged files.

CWindow Overview | Class Members


CWindow::DrawMenuBar

BOOL DrawMenuBar( );

See DrawMenuBar in the Win32 SDK.

Remarks

Redraws the window's menu bar.

CWindow Overview | Class Members

See Also CWindow::GetMenu, CWindow::SetMenu


CWindow::EnableScrollBar

BOOL EnableScrollBar( UINT uSBFlags, UINT uArrowFlags = ESB_ENABLE_BOTH );

See EnableScrollBar in the Win32 SDK.

Remarks

Enables or disables the scroll bar arrows.

CWindow Overview | Class Members

See Also CWindow::ShowScrollBar


CWindow::EnableWindow

BOOL EnableWindow( BOOL bEnable = TRUE );

See EnableWindow in the Win32 SDK.

Remarks

Enables or disables input.

CWindow Overview | Class Members

See Also CWindow::IsWindowEnabled


CWindow::EndPaint

void EndPaint( LPPAINTSTRUCT lpPaint );

See EndPaint in the Win32 SDK.

Remarks

Marks the end of painting.

CWindow Overview | Class Members

See Also CWindow::BeginPaint


CWindow::FlashWindow

BOOL FlashWindow( BOOL bInvert );

See FlashWindow in the Win32 SDK.

Remarks

Flashes the window once.

CWindow Overview | Class Members

See Also CWindow::SetTimer


CWindow::GetClientRect

BOOL GetClientRect( LPRECT lpRect ) const;

See GetClientRect in the Win32 SDK.

Remarks

Retrieves the coordinates of the client area.

CWindow Overview | Class Members

See Also CWindow::GetWindowRect


CWindow::GetDC

HDC GetDC( );

See GetDC in the Win32 SDK.

Remarks

Retrieves a device context for the client area.

CWindow Overview | Class Members

See Also CWindow::GetDCEx, CWindow::GetWindowDC, CWindow::ReleaseDC


CWindow::GetDCEx

HDC GetDCEx( HRGN hRgnClip, DWORD flags );

See GetDCEx in the Win32 SDK.

Remarks

Retrieves a device context for the client area and allows clipping options.

CWindow Overview | Class Members

See Also CWindow::GetDC, CWindow::GetWindowDC, CWindow::ReleaseDC


CWindow::GetDescendantWindow

HWND GetDescendantWindow( int nID ) const;

Return Value

The handle to a descendant window.

Parameters

nID [in] The identifier of the descendant window to be retrieved.

Remarks

Finds the descendant window specified by the given identifier. GetDescendantWindow searches the entire tree of child windows, not only the windows that are immediate children.

CWindow Overview | Class Members

See Also CWindow::GetDlgItem


CWindow::GetDlgCtrlID

int GetDlgCtrlID( ) const;

See GetDlgCtrlID in the Win32 SDK.

Remarks

Retrieves the window's identifier (for child windows only).

CWindow Overview | Class Members

See Also CWindow::SetDlgCtrlID


CWindow::GetDlgItem

HWND GetDlgItem( int nID ) const;

See GetDlgItem in the Win32 SDK.

Remarks

Retrieves the specified child window.

CWindow Overview | Class Members

See Also CWindow::GetDescendantWindow


CWindow::GetDlgItemInt

UINT GetDlgItemInt( int nID, BOOL* lpTrans = NULL, BOOL bSigned = TRUE ) const;

See GetDlgItemInt in the Win32 SDK.

Remarks

Translates a control's text to an integer.

CWindow Overview | Class Members

See Also CWindow::SetDlgItemInt, CWindow::GetDlgItemText


CWindow::GetDlgItemText

UINT GetDlgItemText( int nID, LPTSTR lpStr, int nMaxCount ) const;
BOOL GetDlgItemText( int nID, BSTR& bstrText ) const;

See GetDlgItemText in the Win32 SDK.

Remarks

Retrieves a control's text. The second version of this method allows you to copy the control's text to a BSTR. This version returns TRUE if the text is successfully copied; otherwise, FALSE.

CWindow Overview | Class Members

See Also CWindow::SetDlgItemText, CWindow::GetDlgItem


CWindow::GetExStyle

DWORD GetExStyle( ) const;

Return Value

The window's extended styles.

Remarks

Retrieves the extended window styles of the window.

To retrieve the regular window styles, call GetStyle.

CWindow Overview | Class Members

See Also CWindow::ModifyStyleEx


CWindow::GetFont

HFONT GetFont( ) const;

Return Value

A font handle.

Remarks

Retrieves the window's current font by sending a WM_GETFONT message to the window.

CWindow Overview | Class Members

See Also CWindow::SetFont


CWindow::GetHotKey

DWORD GetHotKey( WORD& wVirtualKeyCode, WORD& wModifiers ) const;

Return Value

The virtual key code and modifiers for the hot key associated with the window. For a list of possible modifiers, see WM_GETHOTKEY in the Win32 SDK.

Parameters

wVirtualKeyCode [in] Not used.

wModifiers [in] Not used.

Remarks

Determines the hot key associated with the window by sending a WM_GETHOTKEY message.

CWindow Overview | Class Members

See Also CWindow::SetHotKey


CWindow::GetIcon

HICON GetIcon( BOOL bBigIcon = TRUE ) const;

Return Value

An icon handle.

Parameters

bBigIcon [in] If TRUE (the default value) the method returns the large icon. Otherwise, it returns the small icon.

Remarks

Retrieves the handle to the window's large or small icon. GetIcon sends a WM_GETICON message to the window.

CWindow Overview | Class Members

See Also CWindow::SetIcon


CWindow::GetLastActivePopup

HWND GetLastActivePopup( ) const;

See GetLastActivePopup in the Win32 SDK.

Remarks

Retrieves the most recently active pop-up window.

CWindow Overview | Class Members


CWindow::GetMenu

HMENU GetMenu( ) const;

See GetMenu in the Win32 SDK.

Remarks

Retrieves the window's menu.

CWindow Overview | Class Members

See Also CWindow::SetMenu


CWindow::GetNextDlgGroupItem

HWND GetNextDlgGroupItem( HWND hWndCtl, BOOL bPrevious = FALSE ) const;

See GetNextDlgGroupItem in the Win32 SDK.

Remarks

Retrieves the previous or next control within a group of controls.

CWindow Overview | Class Members

See Also CWindow::GetNextDlgTabItem


CWindow::GetNextDlgTabItem

HWND GetNextDlgTabItem( HWND hWndCtl, BOOL bPrevious = FALSE ) const;

See GetNextDlgTabItem in the Win32 SDK.

Remarks

Retrieves the previous or next control having the WS_TABSTOP style.

CWindow Overview | Class Members

See Also CWindow::GetNextDlgGroupItem


CWindow::GetParent

HWND GetParent( ) const;

See GetParent in the Win32 SDK.

Remarks

Retrieves the immediate parent window.

CWindow Overview | Class Members

See Also CWindow::SetParent


CWindow::GetScrollPos

int GetScrollPos( int nBar ) const;

See GetScrollPos in the Win32 SDK.

Remarks

Retrieves the position of the scroll box.

CWindow Overview | Class Members

See Also CWindow::SetScrollPos


CWindow::GetScrollRange

BOOL GetScrollRange( int nBar, LPINT lpMinPos, LPINT lpMaxPos ) const;

See GetScrollRange in the Win32 SDK.

Remarks

Retrieves the scroll bar range.

CWindow Overview | Class Members

See Also CWindow::SetScrollRange


CWindow::GetStyle

DWORD GetStyle( ) const;

Return Value

The window's styles.

Remarks

Retrieves the window styles of the window.

To retrieve the extended window styles, call GetExStyle.

CWindow Overview | Class Members

See Also CWindow::ModifyStyle


CWindow::GetSystemMenu

HMENU GetSystemMenu( BOOL bRevert ) const;

See GetSystemMenu in the Win32 SDK.

Remarks

Creates a copy of the system menu for modification.

CWindow Overview | Class Members

See Also CWindow::GetMenu


CWindow::GetTopLevelParent

HWND GetTopLevelParent( ) const;

Return Value

The handle to the top-level parent window.

Remarks

Retrieves the window's top-level parent window.

CWindow Overview | Class Members

See Also CWindow::GetParent, CWindow::GetTopLevelWindow, CWindow::GetWindow


CWindow::GetTopLevelWindow

HWND GetTopLevelWindow( ) const;

Return Value

The handle to the top-level owner window.

Remarks

Retrieves the window's top-level parent or owner window.

CWindow Overview | Class Members

See Also CWindow::GetTopLevelParent, CWindow::GetWindow


CWindow::GetTopWindow

HWND GetTopWindow( ) const;

See GetTopWindow in the Win32 SDK.

Remarks

Retrieves the top-level child window.

CWindow Overview | Class Members

See Also CWindow::GetWindow


CWindow::GetUpdateRect

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

See GetUpdateRect in the Win32 SDK.

Remarks

Retrieves the coordinates of the smallest rectangle that completely encloses the update region.

CWindow Overview | Class Members

See Also CWindow::GetUpdateRgn


CWindow::GetUpdateRgn

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

See GetUpdateRgn in the Win32 SDK.

Remarks

Retrieves the update region and copies it into a specified region.

CWindow Overview | Class Members

See Also CWindow::GetUpdateRect


CWindow::GetWindow

HWND GetWindow( UINT nCmd ) const;

See GetWindow in the Win32 SDK.

Remarks

Retrieves the specified window.

CWindow Overview | Class Members

See Also CWindow::GetTopWindow, CWindow::GetTopLevelParent, CWindow::GetTopLevelWindow


CWindow::GetWindowContextHelpId

DWORD GetWindowContextHelpId( ) const;

See GetWindowContextHelpId in the Win32 SDK.

Remarks

Retrieves the window's help context identifier.

CWindow Overview | Class Members

See Also CWindow::SetWindowContextHelpId


CWindow::GetWindowDC

HDC GetWindowDC( );

See GetWindowDC in the Win32 SDK.

Remarks

Retrieves a device context for the entire window.

CWindow Overview | Class Members

See Also CWindow::GetDC, CWindow::GetDCEx, CWindow::ReleaseDC


CWindow::GetWindowLong

LONG GetWindowLong( int nIndex ) const;

See GetWindowLong in the Win32 SDK.

Remarks

Retrieves a 32-bit value at a specified offset into the extra window memory.

CWindow Overview | Class Members

See Also CWindow::SetWindowLong, CWindow::GetWindowWord


CWindow::GetWindowPlacement

BOOL GetWindowPlacement( WINDOWPLACEMENT FAR* lpwndpl ) const;

See GetWindowPlacement in the Win32 SDK.

Remarks

Retrieves the show state and positions.

CWindow Overview | Class Members

See Also CWindow::SetWindowPlacement


CWindow::GetWindowRect

BOOL GetWindowRect( LPRECT lpRect ) const;

See GetWindowRect in the Win32 SDK.

Remarks

Retrieves the window's bounding dimensions.

CWindow Overview | Class Members

See Also CWindow::GetClientRect


CWindow::GetWindowText

int GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const;
BOOL GetWindowText( BSTR& bstrText );

See GetWindowText in the Win32 SDK.

Remarks

Retrieves the window's text. The second version of this method allows you to store the text in a BSTR. If the text is successfully copied, the return value is TRUE; otherwise, the return value is FALSE.

CWindow Overview | Class Members

See Also CWindow::GetWindowTextLength, CWindow::SetWindowText


CWindow::GetWindowTextLength

int GetWindowTextLength( ) const;

See GetWindowTextLength in the Win32 SDK.

Remarks

Retrieves the length of the window's text.

CWindow Overview | Class Members

See Also CWindow::GetWindowText


CWindow::GetWindowWord

WORD GetWindowWord( int nIndex ) const;

See GetWindowWord in the Win32 SDK.

Remarks

Retrieves a 16-bit value at a specified offset into the extra window memory.

CWindow Overview | Class Members

See Also CWindow::SetWindowWord, CWindow::GetWindowLong


CWindow::HideCaret

BOOL HideCaret( );

See HideCaret in the Win32 SDK.

Remarks

Hides the system caret.

CWindow Overview | Class Members

See Also CWindow::ShowCaret


CWindow::HiliteMenuItem

BOOL HiliteMenuItem( HMENU hMenu, UINT uHiliteItem, UINT uHilite );

See HiliteMenuItem in the Win32 SDK.

Remarks

Highlights or removes the highlight from a top-level menu item.

CWindow Overview | Class Members


CWindow::Invalidate

BOOL Invalidate( BOOL bErase = TRUE );

See InvalidateRect in the Win32 SDK.

Remarks

Invalidates the entire client area. Passes NULL for the RECT parameter to the InvalidateRect Win32 function.

CWindow Overview | Class Members

See Also CWindow::InvalidateRect, CWindow::InvalidateRgn, CWindow::ValidateRect, CWindow::ValidateRgn


CWindow::InvalidateRect

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

See InvalidateRect in the Win32 SDK.

Remarks

Invalidates the client area within the specified rectangle.

CWindow Overview | Class Members

See Also CWindow::Invalidate, CWindow::InvalidateRgn, CWindow::ValidateRect


CWindow::InvalidateRgn

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

See InvalidateRgn in the Win32 SDK.

Remarks

Invalidates the client area within the specified region. Specifies a void return type, while the InvalidateRgn Win32 function always returns TRUE.

CWindow Overview | Class Members

See Also CWindow::Invalidate, CWindow::InvalidateRect, CWindow::ValidateRgn


CWindow::IsChild

BOOL IsChild( const HWND hWnd ) const;

See IsChild in the Win32 SDK.

Remarks

Determines whether the specified window is a child window.

CWindow Overview | Class Members


CWindow::IsDlgButtonChecked

UINT IsDlgButtonChecked( int nIDButton ) const;

See IsDlgButtonChecked in the Win32 SDK.

Remarks

Determines the check state of the button.

CWindow Overview | Class Members

See Also CWindow::CheckDlgButton


CWindow::IsIconic

BOOL IsIconic( ) const;

See IsIconic in the Win32 SDK.

Remarks

Determines whether the window is minimized.

CWindow Overview | Class Members

See Also CWindow::IsZoomed


CWindow::IsWindowEnabled

BOOL IsWindowEnabled( ) const;

See IsWindowEnabled in the Win32 SDK.

Remarks

Determines whether the window is enabled for input.

CWindow Overview | Class Members

See Also CWindow::EnableWindow, CWindow::IsWindowVisible


CWindow::IsWindowVisible

BOOL IsWindowVisible( ) const;

See IsWindowVisible in the Win32 SDK.

Remarks

Determines the window's visibility state.

CWindow Overview | Class Members


CWindow::IsZoomed

BOOL IsZoomed( ) const;

See IsZoomed in the Win32 SDK.

Remarks

Determines whether the window is maximized.

CWindow Overview | Class Members

See Also CWindow::IsIconic


CWindow::KillTimer

BOOL KillTimer( UINT nIDEvent );

See KillTimer in the Win32 SDK.

Remarks

Destroys a timer event.

CWindow Overview | Class Members

See Also CWindow::SetTimer


CWindow::LockWindowUpdate

BOOL LockWindowUpdate( BOOL bLock = TRUE );

Return Value

TRUE if the window is successfully locked; otherwise, FALSE.

Parameters

bLock [in] If TRUE (the default value), the window will be locked. Otherwise, it will be unlocked.

Remarks

Disables or enables drawing in the window by calling the LockWindowUpdate Win32 function. If bLock is TRUE, this method passes m_hWnd to the Win32 function; otherwise, it passes NULL.

CWindow Overview | Class Members


CWindow::MapWindowPoints

int MapWindowPoints( HWND hWndTo, LPPOINT lpPoint, UINT nCount ) const;
int MapWindowPoints( HWND hWndTo, LPRECT lpRect ) const;

See MapWindowPoints in the Win32 SDK.

Remarks

Converts a set of points from the window's coordinate space to the coordinate space of another window. The second version of this method allows you to convert the coordinates of a RECT structure.

CWindow Overview | Class Members


CWindow::MessageBox

int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK );

See MessageBox in the Win32 SDK.

Remarks

Displays a message box.

CWindow Overview | Class Members


CWindow::ModifyStyle

BOOL ModifyStyle( DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0 );

Return Value

TRUE if the window styles are modified; otherwise, FALSE.

Parameters

dwRemove [in] Specifies the window styles to be removed during style modification.

dwAdd [in] Specifies the window styles to be added during style modification.

nFlags [in] Window-positioning flags. For a list of possible values, see the SetWindowPos function in the Win32 SDK.

Remarks

Modifies the window styles of the CWindow object. Styles to be added or removed can be combined by using the bitwise OR ( | ) operator. See the CreateWindow function in the Win32 SDK for information about the available window styles.

If nFlags is nonzero, ModifyStyle calls the Win32 function SetWindowPos, and redraws the window by combining nFlags with the following four flags:

To modify a window's extended styles, call ModifyStyleEx.

CWindow Overview | Class Members

See Also CWindow::GetStyle


CWindow::ModifyStyleEx

BOOL ModifyStyleEx( DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0 );

Return Value

TRUE if the extended window styles are modified; otherwise, FALSE.

Parameters

dwRemove [in] Specifies the extended styles to be removed during style modification.

dwAdd [in] Specifies the extended styles to be added during style modification.

nFlags [in] Window-positioning flags. For a list of possible values, see the SetWindowPos function in the Win32 SDK.

Remarks

Modifies the extended window styles of the CWindow object. Styles to be added or removed can be combined by using the bitwise OR ( | ) operator. See the CreateWindowEx function in the Win32 SDK for information about the available extended styles.

If nFlags is nonzero, ModifyStyleEx calls the Win32 function SetWindowPos, and redraws the window by combining nFlags with the following four flags:

To modify windows using regular window styles, call ModifyStyle.

CWindow Overview | Class Members

See Also CWindow::GetExStyle


CWindow::MoveWindow

BOOL MoveWindow( int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE );
BOOL MoveWindow( LPCRECT lpRect, BOOL bRepaint = TRUE );

See MoveWindow in the Win32 SDK.

Remarks

Changes the window's size and position. The second version of this method uses a RECT structure to determine the window's new position, width, and height.

CWindow Overview | Class Members

See Also CWindow::SetWindowPos


CWindow::OpenClipboard

BOOL OpenClipboard( );

See OpenClipboard in the Win32 SDK.

Remarks

Opens the Clipboard.

CWindow Overview | Class Members


CWindow::PostMessage

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

See PostMessage in the Win32 SDK.

Remarks

Places a message in the message queue associated with the thread that created the window. Returns without waiting for the thread to process the message.

CWindow Overview | Class Members

See Also CWindow::SendMessage, CWindow::SendNotifyMessage


CWindow::Print

void Print( HDC hDC, DWORD dwFlags ) const;

Parameters

hDC [in] The handle to a device context.

dwFlags [in] Specifies the drawing options. You can combine one or more of the following flags:

Remarks

Sends a WM_PRINT message to the window to request that it draw itself in the specified device context.

CWindow Overview | Class Members

See Also CWindow::PrintClient


CWindow::PrintClient

void PrintClient( HDC hDC, DWORD dwFlags ) const;

Parameters

hDC [in] The handle to a device context.

dwFlags [in] Specifies drawing options. You can combine one or more of the following flags:

Remarks

Sends a WM_PRINTCLIENT message to the window to request that it draw its client area in the specified device context.

CWindow Overview | Class Members

See Also CWindow::Print


CWindow::RedrawWindow

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

See RedrawWindow in the Win32 SDK.

Remarks

Updates a specified rectangle or region in the client area.

CWindow Overview | Class Members

See Also CWindow::UpdateWindow


CWindow::ReleaseDC

int ReleaseDC( HDC hDC );

See ReleaseDC in the Win32 SDK.

Remarks

Releases a device context.

CWindow Overview | Class Members

See Also CWindow::GetDC, CWindow::GetDCEx, CWindow::GetWindowDC


CWindow::ScreenToClient

BOOL ScreenToClient( LPPOINT lpPoint ) const;
BOOL ScreenToClient( LPRECT lpRect ) const;

See ScreenToClient in the Win32 SDK.

Remarks

Converts screen coordinates to client coordinates. The second version of this method allows you to convert the coordinates of a RECT structure.

CWindow Overview | Class Members

See Also CWindow::ClientToScreen


CWindow::ScrollWindow

BOOL ScrollWindow( int xAmount, int yAmount, LPCRECT lpRect = NULL, LPCRECT lpClipRect = NULL );

See ScrollWindow in the Win32 SDK.

Remarks

Scrolls the specified client area.

CWindow Overview | Class Members

See Also CWindow::ScrollWindowEx


CWindow::ScrollWindowEx

int ScrollWindowEx( int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate, UINT flags );

See ScrollWindowEx in the Win32 SDK.

Remarks

Scrolls the specified client area with additional features.

CWindow Overview | Class Members

See Also CWindow::ScrollWindow


CWindow::SendDlgItemMessage

LRESULT SendDlgItemMessage( int nID, UINT message, WPARAM wParam = 0, LPARAM lParam = 0 );

See SendDlgItemMessage in the Win32 SDK.

Remarks

Sends a message to a control.

CWindow Overview | Class Members

See Also CWindow::SendMessage


CWindow::SendMessage

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

See SendMessage in the Win32 SDK.

Remarks

Sends a message to the window and does not return until the window procedure has processed the message.

CWindow Overview | Class Members

See Also CWindow::PostMessage, CWindow::SendNotifyMessage, CWindow::SendMessageToDescendants


CWindow::SendMessageToDescendants

void SendMessageToDescendants( UINT message, WPARAM wParam = 0, LPARAM lParam = 0, BOOL bDeep = TRUE );

Parameters

message [in] The message to be sent.

wParam [in] Additional message-specific information.

lParam [in] Additional message-specific information.

bDeep [in] If TRUE (the default value), the message will be sent to all descendant windows; otherwise, it will be sent only to the immediate child windows.

Remarks

Sends the specified message to all immediate children of the CWindow object. If bDeep is TRUE, the message is additionally sent to all other descendant windows.

CWindow Overview | Class Members

See Also CWindow::SendMessage, CWindow::SendNotifyMessage, CWindow::PostMessage


CWindow::SendNotifyMessage

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

See SendNotifyMessage in the Win32 SDK.

Remarks

Sends a message to the window. If the window was created by the calling thread, SendNotifyMessage does not return until the window procedure has processed the message. Otherwise, it returns immediately.

CWindow Overview | Class Members

See Also CWindow::SendMessage, CWindow::SendMessageToDescendants, CWindow::PostMessage


CWindow::SetActiveWindow

HWND SetActiveWindow( );

See SetActiveWindow in the Win32 SDK.

Remarks

Activates the window.

CWindow Overview | Class Members


CWindow::SetCapture

HWND SetCapture( );

See SetCapture in the Win32 SDK.

Remarks

Sends all subsequent mouse input to the window.

CWindow Overview | Class Members


CWindow::SetClipboardViewer

HWND SetClipboardViewer( );

See SetClipboardViewer in the Win32 SDK.

Remarks

Adds the window to the Clipboard viewer chain.

CWindow Overview | Class Members

See Also CWindow::ChangeClipboardChain


CWindow::SetDlgCtrlID

int SetDlgCtrlID( int nID );

Return Value

If successful, the previous identifier of the window; otherwise 0.

Parameters

nID [in] The new value to set for the window's identifier.

Remarks

Sets the identifier of the window to the specified value.

CWindow Overview | Class Members

See Also CWindow::GetDlgCtrlID


CWindow::SetDlgItemInt

BOOL SetDlgItemInt( int nID, UINT nValue, BOOL bSigned = TRUE );

See SetDlgItemInt in the Win32 SDK.

Remarks

Changes a control's text to the string representation of an integer value.

CWindow Overview | Class Members

See Also CWindow::GetDlgItemInt, CWindow::SetDlgItemText


CWindow::SetDlgItemText

BOOL SetDlgItemText( int nID, LPCTSTR lpszString );

See SetDlgItemText in the Win32 SDK.

Remarks

Changes a control's text.

CWindow Overview | Class Members

See Also CWindow::GetDlgItemText, CWindow::SetDlgItemInt


CWindow::SetFocus

HWND SetFocus( );

See SetFocus in the Win32 SDK.

Remarks

Sets the input focus to the window.

CWindow Overview | Class Members


CWindow::SetFont

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

Parameters

hFont [in] The handle to the new font.

bRedraw [in] If TRUE (the default value), the window is redrawn. Otherwise, it is not.

Remarks

Changes the window's current font by sending a WM_SETFONT message to the window.

CWindow Overview | Class Members

See Also CWindow::GetFont


CWindow::SetHotKey

int SetHotKey( WORD wVirtualKeyCode, WORD wModifiers );

Return Value

For a list of possible return values, see WM_SETHOTKEY in the Win32 SDK.

Parameters

wVirtualKeyCode [in] The virtual key code of the hot key.

wModifiers [in] The modifiers of the hot key. For a list of possible values, see WM_SETHOTKEY in the Win32 SDK.

Remarks

Associates a hot key with the window by sending a WM_SETHOTKEY message.

CWindow Overview | Class Members

See Also CWindow::GetHotKey


CWindow::SetIcon

HICON SetIcon( HICON hIcon, BOOL bBigIcon = TRUE );

Return Value

The handle to the previous icon.

Parameters

hIcon [in] The handle to a new icon.

bBigIcon [in] If TRUE (the default value), the method sets a large icon. Otherwise, it sets a small icon.

Remarks

Sets the window's large or small icon to the icon identified by hIcon. SetIcon sends a WM_SETICON message to the window.

CWindow Overview | Class Members

See Also CWindow::GetIcon


CWindow::SetMenu

BOOL SetMenu( HMENU hMenu );

See SetMenu in the Win32 SDK.

Remarks

Changes the window's current menu.

CWindow Overview | Class Members

See Also CWindow::GetMenu


CWindow::SetParent

HWND SetParent( HWND hWndNewParent );

See SetParent in the Win32 SDK.

Remarks

Changes the parent window.

CWindow Overview | Class Members

See Also CWindow::GetParent


CWindow::SetRedraw

void SetRedraw( BOOL bRedraw = TRUE );

Parameters

bRedraw [in] Specifies the state of the redraw flag. If TRUE (the default value), the redraw flag is set; if FALSE, the flag is cleared.

Remarks

Sets or clears the redraw flag by sending a WM_SETREDRAW message to the window. Call SetRedraw to allow changes to be redrawn or to prevent changes from being redrawn.

CWindow Overview | Class Members


CWindow::SetScrollPos

int SetScrollPos( int nBar, int nPos, BOOL bRedraw = TRUE );

See SetScrollPos in the Win32 SDK.

Remarks

Changes the position of the scroll box.

CWindow Overview | Class Members

See Also CWindow::GetScrollPos


CWindow::SetScrollRange

BOOL SetScrollRange( int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE );

See SetScrollRange in the Win32 SDK.

Remarks

Changes the scroll bar range.

CWindow Overview | Class Members

See Also CWindow::GetScrollRange


CWindow::SetTimer

UINT SetTimer( UINT nIDEvent, UINT nElapse, void ( CALLBACK EXPORT* lpfnTimer )( HWND, UINT, UINT, DWORD ) );

See SetTimer in the Win32 SDK.

Remarks

Creates a timer event.

CWindow Overview | Class Members

See Also CWindow::KillTimer


CWindow::SetWindowContextHelpId

BOOL SetWindowContextHelpId( DWORD dwContextHelpId );

See SetWindowContextHelpId in the Win32 SDK.

Remarks

Sets the window's help context identifier.

CWindow Overview | Class Members

See Also CWindow::GetWindowContextHelpId


CWindow::SetWindowLong

LONG SetWindowLong( int nIndex, LONG dwNewLong );

See SetWindowLong in the Win32 SDK.

Remarks

Sets a 32-bit value at a specified offset into the extra window memory.

CWindow Overview | Class Members

See Also CWindow::GetWindowLong, CWindow::SetWindowWord


CWindow::SetWindowPlacement

BOOL SetWindowPlacement( const WINDOWPLACEMENT FAR*lpwndpl );

See SetWindowPlacement in the Win32 SDK.

Remarks

Sets the show state and positions.

CWindow Overview | Class Members

See Also CWindow::GetWindowPlacement


CWindow::SetWindowPos

BOOL SetWindowPos( HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags );
BOOL SetWindowPos( HWND hWndInsertAfter, LPCRECT lpRect, UINT nFlags );

See SetWindowPos in the Win32 SDK.

Remarks

Sets the size, position, and Z order. The second version of this method uses a RECT structure to set the window's new position, width, and height.

CWindow Overview | Class Members

See Also CWindow::BringWindowToTop, CWindow::MoveWindow


CWindow::SetWindowText

BOOL SetWindowText( LPCTSTR lpszString );

See SetWindowText in the Win32 SDK.

Remarks

Changes the window's text.

CWindow Overview | Class Members

See Also CWindow::GetWindowText


CWindow::SetWindowWord

WORD SetWindowLong( int nIndex, WORD wNewWord );

See SetWindowWord in the Win32 SDK.

Remarks

Sets a 16-bit value at a specified offset into the extra window memory.

CWindow Overview | Class Members

See Also CWindow::GetWindowWord, CWindow::SetWindowLong


CWindow::ShowCaret

BOOL ShowCaret( );

See ShowCaret in the Win32 SDK.

Remarks

Displays the system caret.

CWindow Overview | Class Members

See Also CWindow::HideCaret


CWindow::ShowOwnedPopups

BOOL ShowOwnedPopups( BOOL bShow = TRUE );

See ShowOwnedPopups in the Win32 SDK.

Remarks

Shows or hides the pop-up windows owned by the window.

CWindow Overview | Class Members


CWindow::ShowScrollBar

BOOL ShowScrollBar( UINT nBar, BOOL bShow = TRUE );

See ShowScrollBar in the Win32 SDK.

Remarks

Shows or hides a scroll bar.

CWindow Overview | Class Members


CWindow::ShowWindow

BOOL ShowWindow( int nCmdShow );

See ShowWindow in the Win32 SDK.

Remarks

Sets the window's show state.

CWindow Overview | Class Members


CWindow::UpdateWindow

BOOL UpdateWindow( );

See UpdateWindow in the Win32 SDK.

Remarks

Updates the client area.

CWindow Overview | Class Members

See Also CWindow::RedrawWindow


CWindow::ValidateRect

BOOL ValidateRect( LPCRECT lpRect );

See ValidateRect in the Win32 SDK.

Remarks

Validates the client area within the specified rectangle.

CWindow Overview | Class Members

See Also CWindow::ValidateRgn, CWindow::InvalidateRect


CWindow::ValidateRgn

BOOL ValidateRgn( HRGN hRgn );

See ValidateRgn in the Win32 SDK.

Remarks

Validates the client area within the specified region.

CWindow Overview | Class Members

See Also CWindow::ValidateRect, CWindow::InvalidateRgn


CWindow::WinHelp

BOOL WinHelp( LPCTSTR lpszHelp, UINT nCmd = HELP_CONTEXT, DWORD dwData = 0 );

See WinHelp in the Win32 SDK.

Remarks

Starts Windows Help.

CWindow Overview | Class Members


Operators


CWindow::operator HWND

operator HWND( ) const;

Remarks

Converts a CWindow object to an HWND.

CWindow Overview | Class Members


CWindow::operator =

CWindow& operator =( HWND hWnd );

Remarks

Assigns an HWND to the CWindow object by setting the m_hWnd member to hWnd.

CWindow Overview | Class Members


Data Members


CWindow::m_hWnd

HWND m_hWnd;

Remarks

Contains a handle to the window associated with the CWindow object.

CWindow Overview | Class Members

See Also CWindow::CWindow