Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SSW_8_11.doc
Скачиваний:
2
Добавлен:
01.05.2025
Размер:
5 Мб
Скачать
☆

6. Common control elements

    1. Windows Common Controls

Earlier we have considered so called standard control elements. But beginning on Windows’95, there is appeared the different new elements, called common control elements. They expand the properties of standard elements, adding more possibilities and flexibility of controls. Common control elements improve the interface of any windows application. All that new elements are supported by MFC, beginning in 4.0 version.

The Windows operating system has always provided a number of Windows common controls, and more controls were added for Windows 95. 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 see the table Windows Common Controls and MFC Classes below.

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:

  1. Windows 95

  2. Windows NT, version 3.51 and later

  3. Win32s, version 1.3 (Visual C++ version 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, 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.

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:

  1. CBitmapButton

  2. CCheckListBox

  3. CDragListBox

The table below briefly describes each of the Windows common controls.

Windows Common Controls and MFC Classes

Control

MFC Class

Description

New for 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

edit box

CEdit

boxes for entering text

No

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

progress

CProgressCtrl

window that indicates progress of a long operation

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

The creation and initiation of common controls

To work with common controls, the standard library file AFXCMN.H would be included to the program. It’s need also test, if the library of common controls is simultaneously linked with the program (COMCTL32.LIB). As a rule, that program is automatically included to the MFC program, but different compilers can do that in different manner.

In the application, with uses the common controls, on first their run, the InitCommonControls() API-function must be called. It tests, if the special dynamic library (DLL) is loaded and if the common controls subsystem initiated. It’s prototype:

void InitCommonControls(VOID); // This function does not return a value

That’s better to include the call of that function in the constructor of class to create the main window of application.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]