共用方式為


CWindow Class

This class provides methods for manipulating a window.

Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

class CWindow

Members

Public Constructors

Name

Description

CWindow::CWindow

Constructor.

Public Methods

Name

Description

CWindow::ArrangeIconicWindows

Arranges all minimized child windows.

CWindow::Attach

Attaches a window to the CWindow object.

CWindow::BeginPaint

Prepares the window for painting.

CWindow::BringWindowToTop

Brings the window to the top of the Z order.

CWindow::CenterWindow

Centers the window against a given window.

CWindow::ChangeClipboardChain

Removes the window from the chain of Clipboard viewers.

CWindow::CheckDlgButton

Changes the check state of the specified button.

CWindow::CheckRadioButton

Checks the specified radio button.

CWindow::ChildWindowFromPoint

Retrieves the child window containing the specified point.

CWindow::ChildWindowFromPointEx

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

CWindow::ClientToScreen

Converts client coordinates to screen coordinates.

CWindow::Create

Creates a window.

CWindow::CreateCaret

Creates a new shape for the system caret.

CWindow::CreateGrayCaret

Creates a gray rectangle for the system caret.

CWindow::CreateSolidCaret

Creates a solid rectangle for the system caret.

CWindow::DeferWindowPos

Updates the specified multiple-window-position structure for the specified window.

CWindow::DestroyWindow

Destroys the window associated with the CWindow object.

CWindow::Detach

Detaches the window from the CWindow object.

CWindow::DlgDirList

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

CWindow::DlgDirListComboBox

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

CWindow::DlgDirSelect

Retrieves the current selection from a list box.

CWindow::DlgDirSelectComboBox

Retrieves the current selection from a combo box.

CWindow::DragAcceptFiles

Registers whether the window accepts dragged files.

CWindow::DrawMenuBar

Redraws the window's menu bar.

CWindow::EnableScrollBar

Enables or disables the scroll bar arrows.

CWindow::EnableWindow

Enables or disables input.

CWindow::EndPaint

Marks the end of painting.

CWindow::FlashWindow

Flashes the window once.

CWindow::GetClientRect

Retrieves the coordinates of the client area.

CWindow::GetDC

Retrieves a device context for the client area.

CWindow::GetDCEx

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

CWindow::GetDescendantWindow

Retrieves the specified descendant window.

CWindow::GetDlgControl

Retrieves an interface on the specified control.

CWindow::GetDlgCtrlID

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

CWindow::GetDlgHost

Retrieves a pointer to an interface to the ATL Control hosting container.

CWindow::GetDlgItem

Retrieves the specified child window.

CWindow::GetDlgItemInt

Translates a control's text to an integer.

CWindow::GetDlgItemText

Retrieves a control's text.

CWindow::GetExStyle

Retrieves the extended window styles.

CWindow::GetFont

Retrieves the window's current font.

CWindow::GetHotKey

Determines the hot key associated with the window.

CWindow::GetIcon

Retrieves the window's large or small icon.

CWindow::GetLastActivePopup

Retrieves the most recently active pop-up window.

CWindow::GetMenu

Retrieves the window's menu.

CWindow::GetNextDlgGroupItem

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

CWindow::GetNextDlgTabItem

Retrieves the previous or next control having the WS_TABSTOP style.

CWindow::GetParent

Retrieves the immediate parent window.

CWindow::GetScrollInfo

Retrieves the parameters of a scroll bar.

CWindow::GetScrollPos

Retrieves the position of the scroll box.

CWindow::GetScrollRange

Retrieves the scroll bar range.

CWindow::GetStyle

Retrieves the window styles.

CWindow::GetSystemMenu

Creates a copy of the system menu for modification.

CWindow::GetTopLevelParent

Retrieves the top-level parent or owner window.

CWindow::GetTopLevelWindow

Retrieves the top-level owner window.

CWindow::GetTopWindow

Retrieves the top-level child window.

CWindow::GetUpdateRect

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

CWindow::GetUpdateRgn

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

CWindow::GetWindow

Retrieves the specified window.

CWindow::GetWindowContextHelpId

Retrieves the window's help context identifier.

CWindow::GetWindowDC

Retrieves a device context for the entire window.

CWindow::GetWindowLong

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

CWindow::GetWindowLongPtr

Retrieves information about the specified window, including a value at a specified offset into the extra window memory.

CWindow::GetWindowPlacement

Retrieves the show state and positions.

CWindow::GetWindowProcessID

Retrieves the identifier of the process that created the window.

CWindow::GetWindowRect

Retrieves the window's bounding dimensions.

CWindow::GetWindowRgn

Obtains a copy of the window region of a window.

CWindow::GetWindowText

Retrieves the window's text.

CWindow::GetWindowTextLength

Retrieves the length of the window's text.

CWindow::GetWindowThreadID

Retrieves the identifier of the thread that created the specified window.

CWindow::GetWindowWord

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

CWindow::GotoDlgCtrl

Sets the keyboard focus to a control in the dialog box.

CWindow::HideCaret

Hides the system caret.

CWindow::HiliteMenuItem

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

CWindow::Invalidate

Invalidates the entire client area.

CWindow::InvalidateRect

Invalidates the client area within the specified rectangle.

CWindow::InvalidateRgn

Invalidates the client area within the specified region.

CWindow::IsChild

Determines whether the specified window is a child window.

CWindow::IsDialogMessage

Determines whether a message is intended for the specified dialog box.

CWindow::IsDlgButtonChecked

Determines the check state of the button.

CWindow::IsIconic

Determines whether the window is minimized.

CWindow::IsParentDialog

Determines if the parent window of a control is a dialog window.

CWindow::IsWindow

Determines whether the specified window handle identifies an existing window.

CWindow::IsWindowEnabled

Determines whether the window is enabled for input.

CWindow::IsWindowUnicode

Determines whether the specified window is a native Unicode window.

CWindow::IsWindowVisible

Determines the window's visibility state.

CWindow::IsZoomed

Determines whether the window is maximized.

CWindow::KillTimer

Destroys a timer event.

CWindow::LockWindowUpdate

Disables or enables drawing in the window.

CWindow::MapWindowPoints

Converts a set of points from the window's coordinate space to the coordinate space of another window.

CWindow::MessageBox

Displays a message box.

CWindow::ModifyStyle

Modifies the window styles.

CWindow::ModifyStyleEx

Modifies the extended window styles.

CWindow::MoveWindow

Changes the window's size and position.

CWindow::NextDlgCtrl

Sets the keyboard focus to the next control in the dialog box.

CWindow::OpenClipboard

Opens the Clipboard.

CWindow::PostMessage

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::PrevDlgCtrl

Sets the keyboard focus to the previous control in the dialog box.

CWindow::Print

Requests that the window be drawn in a specified device context.

CWindow::PrintClient

Requests that the window's client area be drawn in a specified device context.

CWindow::RedrawWindow

Updates a specified rectangle or region in the client area.

CWindow::ReleaseDC

Releases a device context.

CWindow::ResizeClient

Resizes the window.

CWindow::ScreenToClient

Converts screen coordinates to client coordinates.

CWindow::ScrollWindow

Scrolls the specified client area.

CWindow::ScrollWindowEx

Scrolls the specified client area with additional features.

CWindow::SendDlgItemMessage

Sends a message to a control.

CWindow::SendMessage

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

CWindow::SendMessageToDescendants

Sends a message to the specified descendant windows.

CWindow::SendNotifyMessage

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::SetActiveWindow

Activates the window.

CWindow::SetCapture

Sends all subsequent mouse input to the window.

CWindow::SetClipboardViewer

Adds the window to the Clipboard viewer chain.

CWindow::SetDlgCtrlID

Changes the window's identifier.

CWindow::SetDlgItemInt

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

CWindow::SetDlgItemText

Changes a control's text.

CWindow::SetFocus

Sets the input focus to the window.

CWindow::SetFont

Changes the window's current font.

CWindow::SetHotKey

Associates a hot key with the window.

CWindow::SetIcon

Changes the window's large or small icon.

CWindow::SetMenu

Changes the window's current menu.

CWindow::SetParent

Changes the parent window.

CWindow::SetRedraw

Sets or clears the redraw flag.

CWindow::SetScrollInfo

Sets the parameters of a scroll bar.

CWindow::SetScrollPos

Changes the position of the scroll box.

CWindow::SetScrollRange

Changes the scroll bar range.

CWindow::SetTimer

Creates a timer event.

CWindow::SetWindowContextHelpId

Sets the window's help context identifier.

CWindow::SetWindowLong

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

CWindow::SetWindowLongPtr

Changes an attribute of the specified window, and also sets a value at the specified offset in the extra window memory.

CWindow::SetWindowPlacement

Sets the show state and positions.

CWindow::SetWindowPos

Sets the size, position, and Z order.

CWindow::SetWindowRgn

Sets the window region of a window.

CWindow::SetWindowText

Changes the window's text.

CWindow::SetWindowWord

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

CWindow::ShowCaret

Displays the system caret.

CWindow::ShowOwnedPopups

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

CWindow::ShowScrollBar

Shows or hides a scroll bar.

CWindow::ShowWindow

Sets the window's show state.

CWindow::ShowWindowAsync

Sets the show state of a window created by a different thread.

CWindow::UpdateWindow

Updates the client area.

CWindow::ValidateRect

Validates the client area within the specified rectangle.

CWindow::ValidateRgn

Validates the client area within the specified region.

CWindow::WinHelp

Starts Windows Help.

Public Operators

Name

Description

CWindow::operator HWND

Converts the CWindow object to an HWND.

CWindow::operator =

Assigns an HWND to the CWindow object.

Public Data Members

Name

Description

CWindow::m_hWnd

The handle to the window associated with the CWindow object.

CWindow::rcDefault

Contains default window dimensions.

Remarks

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 method

Win32 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 Windows SDK.

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:

  • Specify an HWND in CWindow's constructor.

  • Call CWindow::Attach.

  • Use CWindow's operator =.

  • Create or subclass a window using one of the following classes derived from CWindow:

    CWindowImpl   Allows you to create a new window or subclass an existing window.

    CContainedWindow   Implements a window contained within another object. You can create a new window or subclass an existing window.

    CDialogImpl   Allows you to create a modal or modeless dialog box.

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

Requirements

Header: atlwin.h

See Also

Other Resources

ATL Class Overview