Your browser doesn't support JavaScript Common Controls - Windows Programming

Common Controls

In addition to standard controls, Windows offers an extended set of child controls known as common controls that can further enhance interaction with the user. To use these common controls, an application must include the header file commctrl.h and call the function InitCommonControlsEx() to ensure that the appropriate components are loaded and initialised. This is necessary because common controls are not referenced in the standard Windows header files.

The prototype for the InitCommonControlsEx() API function is

BOOL InitCommonControlsEx (INITCOMMONCONTROLSEX const *picce);

Where *picce is a pointer to an INITCOMMONCONTROLSEX structure that determines which control classes will be registered.

The function will return TRUE if successful, or FALSE otherwise.

The prototype of theINITCOMMONCONTROLSEX structure is

typedef struct tagINITCOMMONCONTROLSEX {DWORD dwSize;DWORD dwICC;} INITCOMMONCONTROLSEX, *LPINITCOMMONCONTROLSEX;

where 
dwSize indicates the size of the structure, in bytes
wICC indicates which common control classes will be loaded from the DLL.

Common Controls List

Animation Control

The Animation control allows the creation of a window that displays AVI clips. Animation controls can only display AVI clips that do not contain audio. One common use for animation control is to indicate system activity during a lengthy operation. An example of this type of operation is the “flying folders” file copy progress bar in Windows XP when pieces of paper “fly” from one folder to another while the copy operation executes. An application can send messages to an animation control to open, play, stop, and close the AVI clip.

animate control

For further reading – https://docs.microsoft.com/en-us/windows/win32/controls/animation-control-reference

The following example demonstrates the flying folder avi animation


ComboBoxEx Control

A ComboBoxEx control extends the functionality of the combo box control and provides native support for list item images.

comboxex control


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/comboboxex-control-reference

The following example creates a comboboxex control with 5 items. Each item has an associated bitmap image. Changing the selected item copies the text and icon to a static control.


Date and Time Picker

A date and time picker (DTP) control provides a graphical interface to exchange date and time information with a user. The date can be selected from a calendar, or by using up-down keys; the time can be changed by typing in fields defined by the control’s Format Strings.

data and time picker


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/date-and-time-picker-control-reference

The following short program demonstrates the date-picker control. Changing the date or time causes the static box to be updated with the selected date and time.


Header Control

A header control is a horizontal window used for resizable column headings for columns of data. It can be divided into title sections that correspond to each column below. The header control is useful for listboxes, views, and user-defined list-type windows. By default, the header control contains only a label and dividers however including the HDS_BUTTON parameter will make the header a push button.

header control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/header-control-reference

The following short program creates a simple window with 2 header controls. Clicking either will trigger a message box.


Listview

A list-view control is a window that displays a collection of items. Listviews can display items in several modes with additional information displayed in columns to the right of the item. The ListView control is similar to the ListBox control except it can display its items in many different forms together with subitems for each item.

listview control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/list-view-control-reference

The following example creates a simple listview with 4 items. Changing the selected value will copy the contents of the first column into the static box


Month Calendar Control

The month calendar control provides an intuitive method of entering or selecting a date. The title bar contains two buttons that allow the user to select the previous /next month.

calendar control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/month-calendar-control-reference

 The following example creates a simple calendar control. Changing the date updates the static box


Pager Control

A pager control is a window container used within a window that does not have enough display area to show all the child window content. The pager control allows the user to scroll to the area of the window that is not currently in view.

page scroller control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/pager-control-reference

In the following example, a page controller encloses the toolbar.


Progress Bar

A progress bar is a control that an application can use to indicate the progress of a lengthy operation. It consists of an animated rectangle indicating the operation progression.

progress bar control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/create-progress-bar-controls

In the example below, a timer function increments a progress bar control.


Property Sheets

A property sheet is a modeless dialog box used for displaying and editing the properties of an object. A property sheet will consist of one or more pages. Each page will be associated with a selectable tab. When a property sheet needs to communicate with a page it ends a WM_NOTIFY message. The lParam parameter is the address of an NMHDR structure that includes the window handle to the property sheet dialog box.


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/property-sheet-reference

The following short program displays a property sheet containing 2 pages when the user right mouse clicks. The first page responds to a radio button click by displaying an associated message box. The 2nd page is for display purposes only. Although this simple demonstration does not set any real properties it shows how to create a property page template.



A property sheet can also be used to create a wizard. A wizard consists of a set of dialog boxes for guiding a user through a set of selection options in sequence.

wizard control picture


The following short program displays a simple wizard that contains 3 property pages. Right-clicking anywhere in the window initiates the wizard.


Rebar Control

A rebar control acts as a container for child windows. A rebar control contains one or more bands. Each band can contain one child window. The rebar control allows the resizing and repositioning of child windows assigned to their bands. Each rebar band can contain any combination of a gripper bar, a bitmap, a text label, and a child window.

rebar control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/rebar-controls

The following example demonstrates the rebar control acting as a container for both a button and a textbox.


Rich Edit Control

Rich edit controls provide a user interface for entering formatted text. This formatted text can display various character formats, show paragraphs with different alignments, and include embedded objects.


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/rich-edit-controls

The following example is a simple rich text box offering italic bold and underline formatting options


Status Bar

A status bar is a Horizontal window typically displayed at the bottom of an application window that is used to display information about the current application. Status bars are often divided into parts, called panes with each pane displaying different status information. Status bars can also contain objects of different types, including buttons and progress bars. The window class name for a status bar control is STATUSCLASSNAME.

status bar control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/status-bar-reference

The following example demonstrates a simple status bar with 3 cells


SysLink Control

The syslink control provides a convenient way to embed hypertext links in a window.

syslink control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/syslink-overview

The following example displays a simple window with a clickable link.


Tab Control

A tab control is a window that allows an application to display multiple dialog tabs on a single form allowing an application to fit multiple pages into the same area of a window or dialog box.

tab control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/tab-control-reference

The following example displays a simple adjustable tab control. Pages can be added or deleted by clicking the appropriate button.


Task Dialog

A simple task dialog box can display information and receive simple input from the user. A task dialog differs from a message box by offering far more features.

task dialog control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/task-dialogs-overview

The following short program demonstrates a simple task dialog


Toolbar Control

A toolbar control is usually displayed under the main menu and contains one or more buttons. Each button, when clicked sends a command message to the parent window. A toolbar can also contain other controls such as edit controls or combobox.

See creating toolbar page for a detailed description of the toolbar control.


Tooltip

Tooltips automatically pop up when the user pauses the mouse pointer over an application element and displays a brief message explaining the purpose of a particular feature. Tooltips are part of the help system of an application.

tooltip dialog control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/tooltip-control-reference

The following short program demonstrates a simple tooltip window. Placing the map over the button causes the tooltip to appear


Trackbar Control

The trackbar control allows the user to specify a value by scrolling a selector between its minimum and maximum points. The TrackBar control has two parts: an adjustable thumb or slider, and optional tick marks. When the user moves the slider, using either the mouse or the direction keys, the control sends notification messages to indicate the change.

trackbar control picture


For further reading – https://docs.microsoft.com/en-us/windows/win32/controls/using-trackbar-controls

The following program demonstrates a simple trackbar control with values from 0-100. Changes in value will be reflected in the neighbouring buddy window.


Tree-View Control

A tree-view is a window that displays a hierarchical list of labelled items or nodes. Each item can have an associated number of subitems. The top item in the hierarchy is called the root. If an item has other items below it in the hierarchy, it is referred to as a parent. Items subordinate to parents are called children. The hierarchy may be expanded or collapsed at any level to display or hide child items.

treeview control picture


For further reading – https://docs.microsoft.com/en-us/windows/win32/controls/tree-view-control-reference

The following program demonstrates the Treeview control. Nodes can be added or deleted by clicking the appropriate button.


Updown Control

The Updown or spinner control consists of two buttons displayed as arrows with an optional buddy control. The most common buddy control is an edit box and the combination of the two is called a spinner control. Clicking either of the arrows increments or decrements the value in the edit control.

updown control picture


For further reading https://docs.microsoft.com/en-us/windows/win32/controls/up-down-control-reference

The following short program demonstrates a spinner control. Any changes in the control are reflected in the neighbouring static box.


.