A widget is a window with standardized behaviors. It is generally used for dialog boxes or other windows to act as elements that interact with users. In Visual C ++, you can use three types of controls:
(1) Windows standard controls
Windows standard controls are provided by the Windows operating system and some new controls are provided in Windows 95. All these control objects are programmable. You can add them to the dialog box using the dialog editor provided by Visual C ++. The Microsoft basic class library (MFC) provides classes that encapsulate these controls, which are listed in table 6.1.
Table 6.1 windows standard controls
Widget |
MFC class |
Description |
Animation |
Canimatectrl |
Display consecutive AVI Video Clips |
Button |
Cbutton |
Buttons used to generate certain behaviors, as well as check boxes, radio buttons, and group boxes |
Combo box |
Ccombobox |
Combination of edit box and list box |
Edit box |
Cedit |
Used to type text |
Title Header |
Cheaderctrl |
A button located above a line of text to control the width of the display file |
Hotkey |
Chotkeyctrl |
Used to quickly execute some common operations by pressing a combination of keys |
Image list |
Cimagelist |
A collection of images (typically a set of icons or bitmaps. The image list itself is not a control. It often works with other controls to provide the list of images used by other controls. |
List |
Clistctrl |
Window for displaying the text and its icon list |
List box |
Clistbox |
Including a list of strings |
Progress |
Cprogressctrl |
Used to prompt the progress of user completion in a long operation |
Multi-format text editing |
Cricheditctrl |
Provides a window for text editing with character and paragraph formats. |
Scroll bar |
Cscrollbar |
Provides widgets for the dialog box. |
Slider |
Csliderctrl |
Contains a window with an optional Slider |
Rotate button |
Cspinbuttonctrl |
Provides an arrow that can be used to increase or decrease a value. |
Static text |
Cstatic |
It is often used to provide labels for other controls. |
Status Bar |
Cstatusbarctrl |
Window used to display status information, similar to the cstatusbar of the MFC class |
Continued table 6.1
Widget |
MFC class |
Description |
Tab |
Ctabctrl |
In the tab dialog box or on the properties page, provide a tab with a look similar to the labels used in the notebook. |
Tool bar |
Ctoolbarctrl |
A window with a series of command generation buttons, similar to the ctoolbar of the MFC class |
Tooltip |
Ctooltipctrl |
A small pop-up window that provides a simple description of toolbar buttons or other controls. |
Tree |
Ctreectrl |
Used to display the inheritance structure of a series of items |
As mentioned above, in MFC, The cwnd class is the base class of all window classes. Naturally, it is also the base class of all control classes. Windows standard controls are provided in the following environments:
- Windows 95
- Windows NT 3.51 and later versions
- Win32s 1.3
- Note:
- Visual c ++ 4.2 and later versions do not support win32s.
(2) ActiveX Controls
ActiveX controls can be used in a dialog box or HTML document. This type of control is called an ole control in the past. This book describes ActiveX controls in special chapters. It is pointed out that ActiveX controls use completely different interfaces and implementation methods from standard controls.
(3) Other MFC controls
In addition to Windows standard controls and ActiveX controls compiled by yourself or from third-party software developers, MFC also provides three other controls, which are encapsulated by the following three categories:
- Cbitmapbutton is used to create a button that uses bitmap as a tag. A Bitmap Button can contain up to four bitmap images, which represent the four different states of the buttons.
- The cchecklistbox class is used to create a selection list box. This type of list box contains a check box before each item to determine whether the item is selected.
- The cdraglistbox class is used to create a special list box, which allows users to move list items.
In this chapter, we only describe the first type of controls, namely Windows standard controls. The content involved includes the use of various controls and related skills.