Поделиться через


Controls (MFC)

Controls are objects that users can interact with to enter or manipulate data. They commonly appear in dialog boxes or on toolbars. This topic family covers three main kinds of controls:

  • Windows common controls, including owner-drawn controls

  • ActiveX Controls

  • Other control classes supplied by the Microsoft Foundation Class Library (MFC)

Windows Common Controls

The Windows operating system has always provided a number of Windows common controls. These control objects are programmable, and the Visual C++ dialog editor supports adding them to your dialog boxes. The Microsoft Foundation Class Library (MFC) supplies classes that encapsulate each of these controls, as shown in the table Windows Common Controls and MFC Classes. (Some items in the table have related topics that describe them further. For controls that lack topics, see the documentation for the MFC class.)

Class CWnd is the base class of all window classes, including all of the control classes. The Windows common controls are supported in the following environments:

  • Windows 95, Windows 98, and Windows 2000

  • Windows NT, version 3.51 and later

  • Win32s, version 1.3 (Visual C++ versions 4.2 and later do not support Win32s)

The older common controls — check boxes, combo boxes, edit boxes, list boxes, option buttons, pushbuttons, scroll bar controls, and static controls — were available in earlier versions of Windows as well.

ActiveX Controls

ActiveX controls, formerly known as OLE controls, can be used in dialog boxes in your applications for Windows, or in HTML pages on the World Wide Web. For more information, see MFC ActiveX Controls.

Other MFC Control Classes

In addition to classes that encapsulate all of the Windows common controls and that support programming your own ActiveX controls (or using ActiveX controls supplied by others), MFC supplies the following control classes of its own:

Finding Information About Windows Common Controls

The table below briefly describes each of the Windows common controls, including the control's MFC wrapper class.

Windows Common Controls and MFC Classes

Control

MFC class

Description

New in Windows 95?

animation

CAnimateCtrl

Displays successive frames of an AVI video clip

Yes

button

CButton

Pushbuttons that cause an action; also used for check boxes, radio buttons, and group boxes

No

combo box

CComboBox

Combination of an edit box and a list box

No

date and time picker

CDateTimeCtrl

Allows the user to choose a specific date or time value

Yes

edit box

CEdit

Boxes for entering text

No

extended combo box

CComboBoxEx

A combo box control with the ability to display images

Yes

header

CHeaderCtrl

Button that appears above a column of text; controls width of text displayed

Yes

hotkey

CHotKeyCtrl

Window that enables user to create a "hot key" to perform an action quickly

Yes

image list

CImageList

Collection of images used to manage large sets of icons or bitmaps (image list isn't really a control; it supports lists used by other controls)

Yes

list

CListCtrl

Window that displays a list of text with icons

Yes

list box

CListBox

Box that contains a list of strings

No

month calendar

CMonthCalCtrl

Control that displays date information

Yes

progress

CProgressCtrl

Window that indicates progress of a long operation

Yes

rebar

CRebarCtrl

Tool bar that can contain additional child windows in the form of controls

Yes

rich edit

CRichEditCtrl

Window in which user can edit with character and paragraph formatting (see Classes Related to Rich Edit Controls)

Yes

scroll bar

CScrollBar

Scroll bar used as a control inside a dialog box (not on a window)

No

slider

CSliderCtrl

Window containing a slider control with optional tick marks

Yes

spin button

CSpinButtonCtrl

Pair of arrow buttons user can click to increment or decrement a value

Yes

static-text

CStatic

Text for labeling other controls

No

status bar

CStatusBarCtrl

Window for displaying status information, similar to MFC class CStatusBar

Yes

tab

CTabCtrl

Analogous to the dividers in a notebook; used in "tab dialog boxes" or property sheets

Yes

toolbar

CToolBarCtrl

Window with command-generating buttons, similar to MFC class CToolBar

Yes

tool tip

CToolTipCtrl

Small pop-up window that describes purpose of a toolbar button or other tool

Yes

tree

CTreeCtrl

Window that displays a hierarchical list of items

Yes

What do you want to know more about?

For information about Windows common controls in the Windows SDK, see Common Controls.

See Also

Reference

Dialog Editor

Other Resources

User Interface