Configuring the Windows System

Windows is an operating system (OS) that controls a computer. It enables users to navigate a virtual desktop using text and graphic icons rather than typing commands at a command prompt.

Applications create windows and assign unique identifiers to them. Each window can have one of several general window styles or a class-specific style.

Window Classes

Every window in an application has a class that defines its default behavior. An application can register private classes or use preregistered public ones. A window class consists of elements that an application specifies by using the RegisterClassEx function.

Window classes work with the windows system to provide basic and advanced features for an application’s interface. They also help ensure that the user interface remains responsive to changing device configurations.

For example, an adaptive UI designer might consider the size breakpoints that define each class to ensure that its layout works across different device widths and heights. It might also register custom window procedures to handle system events for a specific class of window, allowing the developer to customize the behavior of its windows.

Each window class requires a unique name that an application uses in its window-creation functions to identify the window class for which it wants the system to create a new window. The lpszClassName member of the WNDCLASSEX structure defines this value. The system associates the class name with a window procedure and a set of styles that the system assigns to a window of this class when it creates one.

Window Procedures

A window procedure, or WndProc, is a user-defined callback function that processes messages sent to a window. A window procedure can be specified when an application registers a window class, or when it creates a new window. A window procedure must return a signed value containing information from the low-order and high-order words of its message parameters (as declared with the LOWORD and HIWORD macros in winuser.h).

An application can subclass a window class by replacing its original window procedure address in the WNDCLASSEX structure. A subclass procedure can intercept messages posted to a window and pass them to the original window procedure before or after processing them.

A window procedure can also be used to process messages sent to a dialog box; these are called dialog box procedures. Windows created with the WM_CREATE_DIALOG_TYPE flag use the same procedures as regular windows. If a window procedure receives a WM_CREATE_DIALOG_TYPE message, the dialog is automatically created and placed in front of any existing windows.

Window Attributes

The following window attributes allow you to configure the behavior of windows. Note that some of these attributes may not work on some systems.

The colormap attribute specifies which hardware colormap best reflects the colors of an x:Input-Output window; the default value is x:Copy-From-Parent. If a child window has a colormap attribute of x:Copy-From-Parent, it shares the parent’s colormap; subsequent changes to the colormap in the parent do not affect the child.

If the bit gravity of a window is x:Forget-Gravity, it ignores any change in the position of its parent when the parent is resized. Otherwise, it sends a :gravity-notify event to its parents whenever its own location changes.

The do-not-propagate-mask attribute specifies which events this x:Input-Output or x:Input-Only window does not want to propagate up to its ancestor windows. It is the bitwise inclusive OR of a mask of all events of type device-event-mask-class, except for those of type x:Key-Press, x:Key-Release, x:Button-Press, and x:Button-Release.

Message Boxes

Message boxes are simple modal dialog boxes that display a message and offer selection options. They work with the message loop to communicate with windows within an application, as well as other applications and system-level device drivers.

The msgbox function takes five parameters: a parent window, a title, a message, and one or more buttons. You can use a style to control the appearance of the message box and specify its modality.

Some of the message box styles are not supported by all operating systems. For more information, see the Windows documentation.

You can use the msgbox function to create a message dialog box that includes a custom icon. The x parameter allows you to define the buttons, the y parameter lets you set a default button, and the z parameter makes the dialog box always visible. You can also add a text string that displays in the caption bar of the dialog box. The msgbox function also supports several system-defined flags to control the behavior of the message box.