Predefined Controls

Windows provides several predefined window classes for controls. Controls belonging to these window classes are called predefined controls. An application creates a predefined control of a particular type by specifying the appropriate window class name in either the CreateWindowEx function or the dialog box template. Predefined window classes are described in the following table.

Window class Description
BUTTON Creates a button control, which notifies the parent window when the user clicks the control.
COMBOBOX Creates a combo box —a combination of list box and edit control — that lets the user select and edit items.
EDIT Creates an edit control, which let the user view and edit text.
LISTBOX Creates a list box, which displays a list from which the user can select one or more items.
SCROLLBAR Creates a scroll bar control, which lets the user choose scroll direction and distance in a related window.
STATIC Creates a static control, which often acts as a label for another control. Static controls can display both text and images such as icons.

Each predefined window class has a corresponding set of control styles that enable an application to vary the appearance and behavior of the controls it creates. For example, the BUTTON class supports styles to create push buttons, radio buttons, check boxes, and group boxes. You specify the style when you create the control.

In addition to control styles, each predefined window class has a corresponding set of notification and control messages. Applications rely on the notification messages to determine when the user has provided input to the controls. For example, a push button sends a BN_CLICKED message to the parent window when the user clicks the button. Applications use the control messages to retrieve information from the controls and to manipulate the appearance and behavior of the controls. For example, an application can send a BM_GETCHECK message to a check box to determine whether it currently contains a check mark.

Most programmers make extensive use of predefined controls in dialog boxes and other windows. Because predefined controls offer many capabilities, a full discussion of each is beyond the scope of this chapter.