Export (0) Print
Expand All

Windows

In a graphical Windows-based application, a window is a rectangular area of the screen where the application displays output and receives input from the user. Therefore, one of the first tasks of a graphical Windows-based application is to create a window.

A window shares the screen with other windows, including those from other applications. Only one window at a time can receive input from the user. The user can use the mouse, keyboard, or other input device to interact with this window and the application that owns it.

In This Section

NameDescription
About Windows

Describes the programming elements that applications use to create and use windows; manage relationships between windows; and size, move, and display windows.

Using Windows

Contains examples that perform tasks associated with using windows.

Window Features

Discusses features of windows such as window types, states, size, and position.

Window Reference

Contains the API reference.

 

Window Functions

NameDescription
AdjustWindowRect

Calculates the required size of the window rectangle, based on the desired client-rectangle size. The window rectangle can then be passed to the CreateWindow function to create a window whose client area is the desired size.

AdjustWindowRectEx

Calculates the required size of the window rectangle, based on the desired size of the client rectangle. The window rectangle can then be passed to the CreateWindowEx function to create a window whose client area is the desired size.

AllowSetForegroundWindow

Enables the specified process to set the foreground window using the SetForegroundWindow function. The calling process must already be able to set the foreground window. For more information, see Remarks later in this topic.

AnimateWindow

Enables you to produce special effects when showing or hiding windows. There are four types of animation: roll, slide, collapse or expand, and alpha-blended fade.

AnyPopup

Indicates whether an owned, visible, top-level pop-up, or overlapped window exists on the screen. The function searches the entire screen, not just the calling application's client area.

ArrangeIconicWindows

Arranges all the minimized (iconic) child windows of the specified parent window.

BeginDeferWindowPos

Allocates memory for a multiple-window- position structure and returns the handle to the structure.

BringWindowToTop

Brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.

CalculatePopupWindowPosition

Calculates an appropriate pop-up window position using the specified anchor point, pop-up window size, flags, and the optional exclude rectangle. When the specified pop-up window size is smaller than the desktop window size, use the CalculatePopupWindowPosition function to ensure that the pop-up window is fully visible on the desktop window, regardless of the specified anchor point.

CascadeWindows

Cascades the specified child windows of the specified parent window.

ChangeWindowMessageFilter

Adds or removes a message from the User Interface Privilege Isolation (UIPI) message filter.

ChangeWindowMessageFilterEx

Modifies the UIPI message filter for a specified window.

ChildWindowFromPoint

Determines which, if any, of the child windows belonging to a parent window contains the specified point. The search is restricted to immediate child windows. Grandchildren, and deeper descendant windows are not searched.

ChildWindowFromPointEx

Determines which, if any, of the child windows belonging to the specified parent window contains the specified point. The function can ignore invisible, disabled, and transparent child windows. The search is restricted to immediate child windows. Grandchildren and deeper descendants are not searched.

CloseWindow

Minimizes (but does not destroy) the specified window.

CreateWindow

Creates an overlapped, pop-up, or child window. It specifies the window class, window title, window style, and (optionally) the initial position and size of the window. The function also specifies the window's parent or owner, if any, and the window's menu.

CreateWindowEx

Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function. For more information about creating a window and for full descriptions of the other parameters of CreateWindowEx, see CreateWindow.

DeferWindowPos

Updates the specified multiple-window – position structure for the specified window. The function then returns a handle to the updated structure. The EndDeferWindowPos function uses the information in this structure to change the position and size of a number of windows simultaneously. The BeginDeferWindowPos function creates the structure.

DeregisterShellHookWindow

Unregisters a specified Shell window that is registered to receive Shell hook messages. It unregisters windows that are registered with a call to the RegisterShellHookWindow function.

DestroyWindow

Destroys the specified window. The function sends WM_DESTROY and WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus from it. The function also destroys the window's menu, flushes the thread message queue, destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window is at the top of the viewer chain).

EndDeferWindowPos

Simultaneously updates the position and size of one or more windows in a single screen-refreshing cycle.

EndTask

Forcibly closes a specified window.

EnumChildProc

Application-defined callback function used with the EnumChildWindows function. It receives the child window handles. The WNDENUMPROC type defines a pointer to this callback function. EnumChildProc is a placeholder for the application-defined function name.

EnumChildWindows

Enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE.

EnumThreadWindows

Enumerates all nonchild windows associated with a thread by passing the handle to each window, in turn, to an application-defined callback function. EnumThreadWindows continues until the last window is enumerated or the callback function returns FALSE. To enumerate child windows of a particular window, use the EnumChildWindows function.

EnumThreadWndProc

An application-defined callback function used with the EnumThreadWindows function. It receives the window handles associated with a thread. The WNDENUMPROC type defines a pointer to this callback function. EnumThreadWndProc is a placeholder for the application-defined function name.

EnumWindows

Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.

EnumWindowsProc

An application-defined callback function used with the EnumWindows or EnumDesktopWindows function. It receives top-level window handles. The WNDENUMPROC type defines a pointer to this callback function. EnumWindowsProc is a placeholder for the application-defined function name.

FindWindow

Retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.

FindWindowEx

Retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. This function does not perform a case-sensitive search.

GetAltTabInfo

Retrieves status information for the specified window if it is the application-switching (ALT+TAB) window.

GetAncestor

Retrieves the handle to the ancestor of the specified window.

GetClientRect

Retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0).

GetDesktopWindow

Returns a handle to the desktop window. The desktop window covers the entire screen. The desktop window is the area on top of which other windows are painted.

GetForegroundWindow

Returns a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.

GetGUIThreadInfo

Retrieves information about the active window or a specified GUI thread.

GetLastActivePopup

Determines which pop-up window owned by the specified window was most recently active.

GetLayeredWindowAttributes

Retrieves the opacity and transparency color key of a layered window.

GetNextWindow

Retrieves a handle to the next or previous window in the Z-Order. The next window is below the specified window; the previous window is above. If the specified window is a topmost window, the function retrieves a handle to the next (or previous) topmost window. If the specified window is a top-level window, the function retrieves a handle to the next (or previous) top-level window. If the specified window is a child window, the function searches for a handle to the next (or previous) child window.

GetParent

Retrieves a handle to the specified window's parent or owner.

GetProcessDefaultLayout

Retrieves the default layout that is used when windows are created with no parent or owner.

GetShellWindow

Returns a handle to the Shell's desktop window.

GetTitleBarInfo

Retrieves information about the specified title bar.

GetTopWindow

Examines the Z order of the child windows associated with the specified parent window and retrieves a handle to the child window at the top of the Z order.

GetWindow

Retrieves a handle to a window that has the specified relationship (Z-Order or owner) to the specified window.

GetWindowDisplayAffinity

Retrieves the current display affinity setting, from any process, for a given window.

GetWindowInfo

Retrieves information about the specified window.

GetWindowModuleFileName

Retrieves the full path and file name of the module associated with the specified window handle.

GetWindowPlacement

Retrieves the show state and the restored, minimized, and maximized positions of the specified window.

GetWindowRect

Retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.

GetWindowText

Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application.

GetWindowTextLength

Retrieves the length, in characters, of the specified window's title bar text (if the window has a title bar). If the specified window is a control, the function retrieves the length of the text within the control. However, GetWindowTextLength cannot retrieve the length of the text of an edit control in another application.

GetWindowThreadProcessId

Retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window.

IsChild

Determines whether a window is a child window or descendant window of a specified parent window. A child window is the direct descendant of a specified parent window if that parent window is in the chain of parent windows; the chain of parent windows leads from the original overlapped or pop-up window to the child window.

IsGUIThread

Determines whether the calling thread is already a GUI thread. It can also optionally convert the thread to a GUI thread.

IsHungAppWindow

Determines whether Windows considers that a specified application is not responding. An application is considered to be not responding if it is not waiting for input, is not in startup processing, and has not called PeekMessage within the internal timeout period of 5 seconds.

IsIconic

Determines whether the specified window is minimized (iconic).

IsProcessDPIAware

Gets a value that indicates if the current process is dots per inch (dpi) aware such that it adjusts the sizes of UI elements to compensate for the dpi setting.

IsWindow

Determines whether the specified window handle identifies an existing window.

IsWindowUnicode

Determines whether the specified window is a native Unicode window.

IsWindowVisible

Retrieves the visibility state of the specified window.

IsZoomed

Determines whether a window is maximized.

LockSetForegroundWindow

The foreground process can call the LockSetForegroundWindow function to disable calls to the SetForegroundWindow function.

LogicalToPhysicalPoint

Converts the logical coordinates of a point in a window to physical coordinates.

MoveWindow

Changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.

OpenIcon

Restores a minimized (iconic) window to its previous size and position; it then activates the window.

PhysicalToLogicalPoint

Converts the physical coordinates of a point in a window to logical coordinates.

RealChildWindowFromPoint

Retrieves a handle to the child window at the specified point. The search is restricted to immediate child windows; grandchildren and deeper descendant windows are not searched.

RealGetWindowClass

Retrieves a string that specifies the window type.

RegisterShellHookWindow

Registers a specified Shell window to receive certain messages for events or notifications that are useful to Shell applications. The event messages received are only those sent to the Shell window associated with the specified window's desktop. Many of the messages are the same as those that can be received after calling the SetWindowsHookEx function and specifying WH_SHELL for the hook type. The difference with RegisterShellHookWindow is that the messages are received through the specified window's WindowProc and not through a call back procedure.

SetForegroundWindow

Puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads.

SetLayeredWindowAttributes

Sets the opacity and transparency color key of a layered window.

SetParent

Changes the parent window of the specified child window.

SetProcessDefaultLayout

Changes the default layout when windows are created with no parent or owner only for the currently running process.

SetProcessDPIAware

Sets the current process as dpi aware.

SetWindowDisplayAffinity

Stores the display affinity setting in kernel mode on the hWnd associated with the window.

SetWindowPlacement

Sets the show state and the restored, minimized, and maximized positions of the specified window.

SetWindowPos

Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

SetWindowText

Changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, SetWindowText cannot change the text of a control in another application.

ShowOwnedPopups

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

ShowWindow

Sets the specified window's show state.

ShowWindowAsync

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

SoundSentry

Triggers a visual signal to indicate that a sound is playing.

SwitchToThisWindow

Switches focus to a specified window and bring it to the foreground.

TileWindows

Tiles the specified child windows of the specified parent window.

UpdateLayeredWindow

Updates the position, size, shape, content, and translucency of a layered window.

UpdateLayeredWindowIndirect

Updates the position, size, shape, content, and translucency of a layered window.

WindowFromPhysicalPoint

Retrieves a handle to the window that contains the specified physical point.

WindowFromPoint

Retrieves a handle to the window that contains the specified point.

WinMain

WinMain is the conventional name for the user-provided entry point for a Windows-based application.

 

Window Macros

NameDescription
GET_X_LPARAM

Retrieves the signed x-coordinate from the given LPARAM value.

GET_Y_LPARAM

Retrieves the signed y-coordinate from the given LPARAM value.

HIBYTE

Retrieves the high-order byte from the given 16-bit value.

HIWORD

Retrieves the high-order word from the given 32-bit value.

LOBYTE

Retrieves the low-order byte from the specified value.

LOWORD

Retrieves the low-order word from the specified value.

MAKELONG

Creates a LONG value by concatenating the specified values.

MAKELPARAM

Creates a value for use as an lParam parameter in a message. The macro concatenates the specified values.

MAKELRESULT

Creates a value for use as a return value from a window procedure. The macro concatenates the specified values.

MAKEWORD

Creates a WORD value by concatenating the specified values.

MAKEWPARAM

Creates a value for use as a wParam parameter in a message. The macro concatenates the specified values.

 

Window Messages

NameDescription
MN_GETHMENU

Gets the HMENU for the current window.

WM_GETFONT

Retrieves the font with which the control is currently drawing its text.

WM_GETTEXT

Copies the text that corresponds to a window into a buffer provided by the caller.

WM_GETTEXTLENGTH

Determine the length, in characters, of the text associated with a window.

WM_SETFONT

Specifies the font that a control is to use when drawing text.

WM_SETICON

Associates a new large or small icon with a window. The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption.

WM_SETTEXT

Sets the text of a window.

 

Window Notifications

NameDescription
WM_ACTIVATEAPP

Sent when a window belonging to a different application than the active window is about to be activated. The message is sent to the application whose window is being activated and to the application whose window is being deactivated.

A window receives this message through its WindowProc function.

WM_CANCELMODE

Sent to cancel certain modes, such as mouse capture. For example, the system sends this message to the active window when a dialog box or message box is displayed. Certain functions also send this message explicitly to the specified window regardless of whether it is the active window. For example, the EnableWindow function sends this message when disabling the specified window.

WM_CHILDACTIVATE

Sent to a child window when the user clicks the window's title bar or when the window is activated, moved, or sized.

WM_CLOSE

Sent as a signal that a window or an application should terminate.

WM_COMPACTING

Sent to all top-level windows when the system detects more than 12.5 percent of system time over a 30- to 60-second interval is being spent compacting memory. This indicates that system memory is low.

WM_CREATE

Sent when an application requests that a window be created by calling the CreateWindowEx or CreateWindow function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible.

WM_DESTROY

Sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen.

This message is sent first to the window being destroyed and then to the child windows (if any) as they are destroyed. During the processing of the message, it can be assumed that all child windows still exist.

WM_ENABLE

Sent when an application changes the enabled state of a window. It is sent to the window whose enabled state is changing. This message is sent before the EnableWindow function returns, but after the enabled state (WS_DISABLED style bit) of the window has changed.

WM_ENTERSIZEMOVE

Sent one time to a window after it enters the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns.

The system sends the WM_ENTERSIZEMOVE message regardless of whether the dragging of full windows is enabled.

WM_ERASEBKGND

Sent when the window background must be erased (for example, when a window is resized). The message is sent to prepare an invalidated portion of a window for painting.

WM_EXITSIZEMOVE

Sent one time to a window, after it has exited the moving or sizing modal loop. The window enters the moving or sizing modal loop when the user clicks the window's title bar or sizing border, or when the window passes the WM_SYSCOMMAND message to the DefWindowProc function and the wParam parameter of the message specifies the SC_MOVE or SC_SIZE value. The operation is complete when DefWindowProc returns.

WM_GETICON

Sent to a window to retrieve a handle to the large or small icon associated with a window. The system displays the large icon in the ALT+TAB dialog, and the small icon in the window caption.

WM_GETMINMAXINFO

Sent to a window when the size or position of the window is about to change. An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.

WM_INPUTLANGCHANGE

Sent to the topmost affected window after an application's input language has been changed. You should make any application-specific settings and pass the message to the DefWindowProc function, which passes the message to all first-level child windows. These child windows can pass the message to DefWindowProc to have it pass the message to their child windows, and so on.

WM_INPUTLANGCHANGEREQUEST

Posted to the window with the focus when the user chooses a new input language, either with the hotkey (specified in the Keyboard control panel application) or from the indicator on the system taskbar. An application can accept the change by passing the message to the DefWindowProc function or reject the change (and prevent it from taking place) by returning immediately.

WM_MOVE

Sent after a window has been moved.

WM_MOVING

Sent to a window that the user is moving. By processing this message, an application can monitor the position of the drag rectangle and, if needed, change its position.

WM_NCACTIVATE

Sent to a window when its nonclient area needs to be changed to indicate an active or inactive state.

WM_NCCALCSIZE

Sent when the size and position of a window's client area must be calculated. By processing this message, an application can control the content of the window's client area when the size or position of the window changes.

WM_NCCREATE

Sent prior to the WM_CREATE message when a window is first created.

WM_NCDESTROY

Informs a window that its nonclient area is being destroyed. The DestroyWindow function sends the WM_NCDESTROY message to the window following the WM_DESTROY message. WM_DESTROY is used to free the allocated memory object associated with the window.

The WM_NCDESTROY message is sent after the child windows have been destroyed. In contrast, WM_DESTROY is sent before the child windows are destroyed.

WM_NULL

Performs no operation. An application sends the WM_NULL message if it wants to post a message that the recipient window will ignore.

WM_PARENTNOTIFY

Sent to the parent of a child window when the child window is created or destroyed, or when the user clicks a mouse button while the cursor is over the child window. When the child window is being created, the system sends WM_PARENTNOTIFY just before the CreateWindow or CreateWindowEx function that creates the window returns. When the child window is being destroyed, the system sends the message before any processing to destroy the window takes place.

WM_QUERYDRAGICON

Sent to a minimized (iconic) window. The window is about to be dragged by the user but does not have an icon defined for its class. An application can return a handle to an icon or cursor. The system displays this cursor or icon while the user drags the icon.

WM_QUERYOPEN

Sent to an icon when the user requests that the window be restored to its previous size and position.

WM_QUIT

Indicates a request to terminate an application, and is generated when the application calls the PostQuitMessage function. It causes the GetMessage function to return zero.

WM_SHOWWINDOW

Sent to a window when the window is about to be hidden or shown.

WM_SIZE

Sent to a window after its size has changed.

WM_SIZING

Sent to a window that the user is resizing. By processing this message, an application can monitor the size and position of the drag rectangle and, if needed, change its size or position.

WM_STYLECHANGED

Ssent to a window after the SetWindowLong function has changed one or more of the window's styles.

WM_STYLECHANGING

Sent to a window when the SetWindowLong function is about to change one or more of the window's styles.

WM_THEMECHANGED

Broadcast to every window following a theme change event. Examples of theme change events are the activation of a theme, the deactivation of a theme, or a transition from one theme to another.

WM_USERCHANGED

Sent to all windows after the user has logged on or off. When the user logs on or off, the system updates the user-specific settings. The system sends this message immediately after updating the settings.

WM_WINDOWPOSCHANGED

Sent to a window whose size, position, or place in the Z order has changed as a result of a call to the SetWindowPos function or another window-management function.

WM_WINDOWPOSCHANGING

Sent to a window whose size, position, or place in the Z order is about to change as a result of a call to the SetWindowPos function or another window-management function.

 

Window Structures

NameDescription
ALTTABINFO

Contains status information for the application-switching (ALT+TAB) window.

CHANGEFILTERSTRUCT

Contains extended result information obtained by calling the ChangeWindowMessageFilterEx function.

CLIENTCREATESTRUCT

Contains information about the menu and first multiple-document interface (MDI) child window of an MDI client window. An application passes a pointer to this structure as the lpParam parameter of the CreateWindow function when creating an MDI client window.

CREATESTRUCT

Defines the initialization parameters passed to the window procedure of an application. These members are identical to the parameters of the CreateWindowEx function.

GUITHREADINFO

Contains information about a GUI thread.

MINMAXINFO

Contains information about a window's maximized size and position and its minimum and maximum tracking size.

NCCALCSIZE_PARAMS

Contains information that an application can use while processing the WM_NCCALCSIZE message to calculate the size, position, and valid contents of the client area of a window.

STYLESTRUCT

Contains the styles for a window.

TITLEBARINFO

Contains title bar information.

TITLEBARINFOEX

Expands on the information described in the TITLEBARINFO structure by including the coordinates of each element of the title bar.

UPDATELAYEREDWINDOWINFO

Used by UpdateLayeredWindowIndirect to provide position, size, shape, content, and translucency information for a layered window.

WINDOWINFO

Contains window information.

WINDOWPLACEMENT

Contains information about the placement of a window on the screen.

WINDOWPOS

Contains information about the size and position of a window.

 

Window Constants

NameDescription
Extended Window Styles

Styles that can be specified wherever an extended window style is required.

Window Styles

Styles that can be specified wherever a window style is required. After the control has been created, these styles cannot be modified, except as noted.

 

 

 

Community Additions

ADD
Show:
© 2014 Microsoft