Public Members

Data Members

m_hWnd Indicates the HWND attached to this CWnd.  
wndTop Indicates a static CWnd to use with the SetWindowPos member function to indicate that CWnd should be moved to the top of the window list.  
wndBottom Indicates a static CWnd to use with the SetWindowPos member function to indicate that CWnd should be moved to the bottom of the window list.  

Construction/Destruction

CWnd Constructs a CWnd object.  
~CWnd Destroys a CWnd object and destroys the attached window.  
DestroyWindow Destroys the attached Windows window.  

Initialization

Create Creates and initializes the child window associated with the CWnd object.  
GetStyle Returns the current window style.  
Attach Attaches a Windows handle to a CWnd object.  
Detach Detaches a Windows handle from a CWnd object and returns the handle.  
FromHandle Returns a pointer to a CWnd object when given a handle to a window. If a CWnd object is not attached to the handle, a temporary CWnd object is created and attached.  
DeleteTempMap Called automatically by the CWinApp idle-time handler and deletes any temporary CWnd objects created by FromHandle.  
GetSafeHwnd Returns m_hWnd, or NULL if this is NULL.  

Message Functions

SendMessage Sends a message to the CWnd object and does not return until it has processed the message.  
PostMessage Places a message in the CWnd object's application queue, then returns without waiting for the object to process the message.  

Window Text Functions

SetWindowText Sets the CWnd text or caption title (if one exists) to the specified text.  
GetWindowText Copies the CWnd text or caption title (if it has one) into a buffer.  
GetWindowTextLength Returns the length of the CWnd text or caption title.  
SetFont Sets the current font.  
GetFont Retrieves the current font.  

CMenu Functions

GetMenu Retrieves a pointer to the menu.  
SetMenu Sets the menu to the specified menu.  
DrawMenuBar Redraws the menu bar.  
GetSystemMenu Allows the application to access the Control menu for copying and modification.  
HiliteMenuItem Highlights or removes the highlighting from a top-level (menu-bar) menu item.  

Child Window Attributes

GetDlgCtrlID If the CWnd is a child window, calling this function returns its ID value.  

Window Size and Position

CloseWindow Minimizes CWnd.  
OpenIcon Activates and restores a minimized (iconic) CWnd.  
IsIconic Determines whether CWnd is minimized (iconic).  
IsZoomed Determines whether CWnd is maximized.  
MoveWindow Changes the position and/or dimensions of CWnd.  
SetWindowPos Changes the size, position, and ordering of child, pop-up, and top-level windows.  
ArrangeIconicWindows Arranges all the minimized (iconic) child windows.  
BringWindowToTop Brings CWnd to the top of a stack of overlapping windows.  
GetWindowRect Gets the screen coordinates of CWnd.  
GetClientRect Gets the dimensions of the CWnd client area.  

Coordinate Mapping Functions

ClientToScreen Converts the client coordinates of a given point or rect on the display to screen coordinates.  
ScreenToClient Converts the screen coordinates of a given point or rect on the display to client coordinates.  

Update/Painting Functions

BeginPaint Prepares CWnd for painting and fills a PAINTSTRUCT data structure with information about the painting.  
EndPaint Marks the end of painting.  
GetDC Retrieves a display context for the client area.  
GetWindowDC Retrieves the display context for the whole window, including the caption bar, menus, and scroll bars.  
ReleaseDC Releases common and window device contexts, freeing them for use by other applications.  
UpdateWindow Updates the client area.  
SetRedraw Allows changes in CWnd to be redrawn or prevents changes from being redrawn.  
GetUpdateRect Retrieves the coordinates of the smallest rectangle that completely encloses the CWnd update region.  
GetUpdateRgn Retrieves the CWnd update region.  
Invalidate Invalidates the entire client area.  
InvalidateRect Invalidates the client area within the given rectangle by adding that rectangle to the update region.  
InvalidateRgn Invalidates the client area within the given region
by adding it to the current update region.
 
ValidateRect Validates the client area within the given rectangle by removing the rectangle from the update region.  
ValidateRgn Validates the client area within the given region
by removing the region from the current update region.
 
ShowWindow Shows or hides CWnd.  
IsWindowVisible Determines if the window is visible.  
ShowOwnedPopups Shows or hides all pop-up windows associated with the window.  

Timer Functions

SetTimer Installs a system timer that sends a WM_TIMER message when triggered.  
KillTimer Kills a system timer.  

Window State Functions

IsWindowEnabled Determines if the window is enabled for mouse and keyboard input.  
EnableWindow Enables or disables mouse and keyboard input.  
GetActiveWindow Retrieves the active window.  
SetActiveWindow Activates the window.  
GetCapture Retrieves the CWnd that has the mouse capture.  
SetCapture Causes all subsequent mouse input to be sent to the CWnd.  
GetFocus Retrieves the CWnd that currently has the input focus.  
SetFocus Assigns the input focus.  
SetSysModalWindow Makes CWnd a system-modal window.  
GetSysModalWindow Retrieves the system-modal CWnd if there is one.  
GetDesktopWindow Retrieves the Windows desktop window.  

Dialog-Box Item Functions

CheckDlgButton Places a check mark next to or removes a check mark from a button control, or dims the button.  
CheckRadioButton Checks the specified radio button and removes the check mark from all other radio buttons in the specified group of buttons.  
GetCheckedRadioButton Returns the ID of the currently checked radio button in a group of buttons.  
DlgDirList Fills a list box with a file or directory listing.  
DlgDirListComboBox Fills the list box of a combo box with a file or directory listing.  
DlgDirSelect Retrieves the current selection from a list box.  
DlgDirSelectComboBox Retrieves the current selection from the list box of a combo box.  
GetDlgItem Retrieves the handle of a control contained in the specified dialog box.  
GetDlgItemInt Translates the text of a control in the given dialog box to an integer value.  
GetDlgItemText Retrieves the caption or text associated with a control.  
GetNextDlgGroupItem Searches for the previous (or next) control within a group of controls.  
GetNextDlgTabItem Retrieves the first control that has the WS_TABSTOP style and precedes (or follows) the specified control.  
IsDlgButtonChecked Determines whether a button control has a check mark next to it, and whether a three-state button control is dimmed, checked, or neither.  
SendDlgItemMessage Sends a message to the specified control.  
SetDlgItemInt Sets the text of a control to the string that represents an integer value.  
SetDlgItemText Sets the caption or text of a control in the specified dialog box.  

Scrolling Functions

GetScrollPos Retrieves the current position of a scroll box.  
GetScrollRange Copies the current minimum and maximum scroll-bar positions for the given scroll bar.  
ScrollWindow Scrolls CWnd.  
SetScrollPos Sets the current position of a scroll box and, if specified, redraws the scroll bar to reflect the new position.  
SetScrollRange Sets minimum and maximum position values for the given scroll bar.  
ShowScrollBar Displays or hides a scroll bar.  

Window Access Functions

ChildWindowFromPoint Determines which, if any, of the child windows contains the specified point.  
FindWindow Returns the handle of the window, which is identified by its window name and class.  
GetNextWindow Searches for the next (or previous) window in the window-manager's list.  
GetTopWindow Searches for a top-level child window that belongs to the CWnd.  
GetWindow Searches for the specified window from the window-manager's list.  
GetLastActivePopup Determines which pop-up window owned by CWnd was most recently active.  
IsChild Indicates whether CWnd is a child window or other direct descendant of the specified window.  
GetParent Retrieves the parent window of CWnd (if any).  
SetParent Changes the parent window.  
WindowFromPoint Identifies the window that contains the given point.  

Alert Functions

FlashWindow Flashes the window once.  
MessageBox Creates and displays a window that contains an application-supplied message and caption.  

Clipboard Functions

ChangeClipboardChain Removes CWnd from the chain of Clipboard viewers.  
SetClipboardViewer Adds CWnd to the chain of windows that are notified whenever the contents of the Clipboard are changed.  
OpenClipboard Opens the Clipboard. Other applications will not be able to modify the Clipboard until the CloseClipboard Windows function is called.  
GetClipboardOwner Retrieves a pointer to the current owner of the Clipboard.  
GetClipboardViewer Retrieves a pointer to the first window in the chain of Clipboard viewers.  

Caret Functions

CreateCaret Creates a new shape for the system caret and gets ownership of the caret.  
CreateSolidCaret Creates a solid block for the system caret and gets ownership of the caret.  
CreateGrayCaret Creates a gray block for the system caret and gets ownership of the caret.  
GetCaretPos Retrieves the client coordinates of the caret's current position.  
SetCaretPos Moves the caret to a specified position.  
HideCaret Hides the caret by removing it from the display screen.  
ShowCaret Shows the caret on the display at the caret's current position. Once shown, the caret begins flashing automatically.  

Message Handlers (require entry in Message Map)

OnCommand Called when the user selects an item from a menu, when a control calls its parent's message handler, or when an access keystroke is translated.  
OnActivate Called when CWnd is being activated or deactivated.  
OnActivateApp Called when CWnd is about to be activated and CWnd belongs to a different task than the currently active window.  
OnCancelMode Called to allow CWnd to cancel any internal modes, such as mouse capture, if CWnd has the focus when a dialog box or message box is displayed.  
OnChildActivate Called whenever the size or position of CWnd changes if CWnd is a child window.  
OnClose Called as a signal that CWnd or an application will terminate.  
OnCreate Called when an application requests that CWnd be created.  
OnCtlColor Called when the control or message box is about to be drawn if CWnd is the parent of a system-defined control class or a message box.  
OnDestroy Called when CWnd is being destroyed.  
OnEnable Called when an application changes the enabled state of CWnd.  
OnEndSession Called when the session is ending.  
OnEnterIdle Called to inform an application's main window procedure that a modal dialog box or a menu is entering an idle state.  
OnEraseBkgnd Called when the background needs erasing.  
OnGetMinMaxInfo Called whenever Windows needs to know the maximized position or dimensions, or the minimum or maximum tracking size.  
OnIconEraseBkgnd Called when CWnd is being minimized (made iconic) and the background of the icon must be filled before painting the icon.  
OnKillFocus Called immediately before CWnd loses the input focus.  
OnMenuChar Called when the user presses a menu mnemonic character that doesn't match any of the predefined mnemonics in the current menu.  
OnMenuSelect Called when the user selects a menu item.  
OnMove Called after the position of CWnd has been changed.  
OnPaint Called when Windows or an application makes a request to repaint a portion of the window.  
OnPaintIcon Called when CWnd is minimized (iconic) and the icon is to be painted.  
OnParentNotify Called when a CWnd child window is created or destroyed, or when the user clicks a mouse button while the cursor is over the child window.  
OnQueryDragIcon Called when a minimized (iconic) CWnd is about to be dragged by the user (if CWnd does not have an icon defined for its class).  
OnQueryEndSession Called when the user chooses to end the Windows session, or when an application calls the ExitWindows Windows function.  
OnQueryNewPalette Informs CWnd that it is about to receive the input focus.  
OnQueryOpen Called when CWnd is an icon, and the user requests that the icon be opened.  
OnSetFocus Called after CWnd gains the input focus.  
OnShowWindow Called when CWnd is to be hidden or shown.  
OnSize Called after the size of CWnd has changed.  

Nonclient-Area Functions

OnNcActivate Called when the nonclient area needs to be changed to indicate an active or inactive state.  
OnNcCalcSize Called when the size of the client area needs to be calculated.  
OnNcCreate Called prior to OnCreate when the nonclient area is being created.  
OnNcDestroy Called when the nonclient area is being destroyed.  
OnNcHitTest Called by Windows every time the mouse is moved if CWnd contains the cursor, or has captured mouse input with SetCapture.  
OnNcLButtonDblClk Called when the user double-clicks the left mouse button while the cursor is within a nonclient area of CWnd.  
OnNcLButtonDown Called when the user presses the left mouse button while the cursor is within a nonclient area of CWnd.  
OnNcLButtonUp Called when the user releases the middle mouse button while the cursor is within a nonclient area of CWnd.  
OnNcMButtonDblClk Called when the user double-clicks the middle mouse button while the cursor is within a nonclient area of CWnd.  
OnNcMButtonDown Called when the user presses the middle mouse button while the cursor is within a nonclient area of CWnd.  
OnNcMButtonUp Called when the user releases the middle mouse button while the cursor is within a nonclient area of CWnd.  
OnNcMouseMove Called when the cursor is moved within a nonclient area of CWnd.  
OnNcPaint Called when the nonclient area needs painting.  
OnNcRButtonDblClk Called when the user double-clicks the right mouse button while the cursor is within a nonclient area of CWnd.  
OnNcRButtonDown Called when the user presses the right mouse button while the cursor is within a nonclient area of CWnd.  
OnNcRButtonUp Called when the user releases the right mouse button while the cursor is within a nonclient area of CWnd.  

System Message Handlers

OnSysChar Called when a keystroke translates to a system character.  
OnSysCommand Called when the user selects a command from the Control menu, or when the user selects the Maximize or Minimize button.  
OnSysDeadChar Called when a keystroke translates to a system dead character (such as accent characters).  
OnSysKeyDown Called when the user holds down the ALT key and then presses another key.  
OnSysKeyUp Called when the user releases a key that was pressed while the ALT key was held down.  
OnCompacting Called when Windows detects that system memory is low.  
OnDevModeChange Called for all top-level windows when the user changes device-mode settings.  
OnFontChange Called when the pool of font resources changes.  
OnPaletteChanged Called to allow windows that don't have the input focus and use a color palette to realize their logical palettes and update their client areas.  
OnSpoolerStatus Called from Print Manager whenever a job is added to or removed from the Print Manager queue.  
OnSysColorChange Called for all top-level windows when a change is made in the system color setting.  
OnTimeChange Called for all top-level windows after the system time changes.  
OnWinIniChange Called for all top-level windows after the Windows initialization file, WIN.INI, is changed.  

Input Message Handlers

OnChar Called when a keystroke translates to a nonsystem character.  
OnDeadChar Called when a keystroke translates to a nonsystem dead character (such as accent characters).  
OnHScroll Called when the user clicks the horizontal scroll bar of CWnd.  
OnKeyDown Called when a nonsystem key is pressed. A nonsystem key is a keyboard key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when CWnd has the input focus.  
OnKeyUp Called when a nonsystem key is released. A nonsystem key is a keyboard key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when CWnd has the input focus.  
OnLButtonDblClk Called when the user double-clicks the left mouse button.  
OnLButtonDown Called when the user presses the left mouse button.  
OnLButtonUp Called when the user releases the left mouse button.  
OnMButtonDblClk Called when the user double-clicks the middle mouse button.  
OnMButtonDown Called when the user presses the middle mouse button.  
OnMButtonUp Called when the user releases the middle mouse button.  
OnMouseActivate Called when the cursor is in an inactive window and the user presses a mouse button.  
OnMouseMove Called when the mouse cursor moves.  
OnRButtonDblClk Called when the user double-clicks the right mouse button.  
OnRButtonDown Called when the user presses the right mouse button.  
OnRButtonUp Called when the user releases the right mouse button.  
OnSetCursor Called if mouse input is not captured and the mouse causes cursor movement within a window.  
OnTimer Called after each interval specified in SetTimer.  
OnVScroll Called when the user clicks the window's vertical scroll bar.  

Initialization Message Handlers

OnInitMenu Called when a menu is about to become active.  
OnInitMenuPopup Called when a pop-up menu is about to become active.  

Clipboard Message Handlers

OnAskCbFormatName Called by a Clipboard viewer application when a Clipboard owner will display the Clipboard contents.  
OnChangeCbChain Notifies that a specified window is being removed from the chain.  
OnDestroyClipboard Called when the Clipboard is emptied through a call to the EmptyClipboard Windows function.  
OnDrawClipboard Called when the contents of the Clipboard change.  
OnHScrollClipboard Called when a Clipboard owner will scroll the Clipboard image, invalidate the appropriate section, and update the scroll-bar values.  
OnPaintClipboard Called when the client area of the Clipboard viewer needs repainting.  
OnRenderAllFormats Called when the owner application is being destroyed and needs to render all its formats.  
OnRenderFormat Called for the Clipboard owner when a particular format with delayed rendering needs to be rendered.  
OnSizeClipboard Called when the size of the client area of the Clipboard-viewer window has changed.  
OnVScrollClipboard Called when the owner should scroll the Clipboard image, invalidate the appropriate section, and update the scroll-bar values.  

Control Message Handlers

OnCharToItem Called by a child list box with the LBS_WANTKEYBOARDINPUT style in response to a WM_CHAR message.  
OnCompareItem Called to determine the relative position of a new item in a sorted owner-draw combo or list box.  
OnDeleteItem Called when an owner-draw list box or combo box is destroyed or when items are removed from the control by calls to CComboBox::DeleteString or CComboBox::ResetContent.  
OnDrawItem Called when a visual aspect of an owner-draw button control, combo box control, list box control, or menu needs to be drawn.  
OnGetDlgCode Called for a control so the control can process ARROW key and TAB key input itself, although Windows normally handles this input.  
OnMeasureItem Called for an owner-draw button, combo box, list box, or menu item when the control is created. CWnd informs Windows of the dimensions of the control.  
OnVKeyToItem Called by a list box owned by CWnd in response to a WM_KEYDOWN message.  

MDI Message Handlers

OnMDIActivate Called when an MDI child window is activated or deactivated.