4.8 KiB
Cool Bar Control
The cool bar control is a toolbar which can display a line of text or icon buttons. The cool bar is very simple and is easy to use.
You can create a cool bar control by calling CreateWindow function with
CTRL_COOLBAR as the control class name.
Styles of Cool Bar
The button items of cool bar with the styles CBS_BMP_16X16 and
CBS_BMP_32X32 will display bitmaps with size of 16x16 and 32x32 respectively.
The button items of a cool bar with CBS_BMP_CUSTOM style will use bitmaps
with customized size. For cool bar controls with this style, you should pass
the height and width of the bitmap to the control through dwAddData argument
when calling CreateWindow to create the control:
A cool bar with CBS_USEBKBMP style has a background bitmap, and you should
pass the path of the bitmap file to the control by spCaption argument of
CreateWindow function when creating the control.
Cool bar cannot accept height when create it.
Messages of Cool Bar
After a cool bar has been created, we can use CBM_ADDITEM message to add
items to the toolbar:
Here itemInfo is a structure of COOLBARITEMINFO type:
Here id is the identifier of the item in a toolbar. When the user clicks the
item, the cool bar will generate notification messages, and the high word
(HIWORD) of wParam is the identifier value of the corresponding item, the
low word (LOWORD) of wParam is the identifier value of the tool Control.
ItemType specifies the type of the item, value of which can be one of
TYPE_BARITEM, TYPE_BMPITEM, and TYPE_TEXTITEM. Item of TYPE_BARITEM is
a vertical separator; item of TYPE_BMPITEM is a bitmap button; and item of
TYPE_TEXTITEM is a text button.
If the type of an item is TYPE_BMPITEM, bmp specifies the bitmap object used
by the item. ItemHint is the prompt text to be displayed when the mouse move
onto the item. If the style of an item is TPYE_TEXTITEM, Caption should point
to the text string displayed on the item.
dwAddData is the additional data of an item.
CBM_ENABLE message disables or enables an item:
Here id is the identifier value of the item to be set. If beEnabled is
TRUE, enable the item and FALSE disable the item.
Sample Program
The program in List 1 illustrates the use of a cool bar control. Please refer to coolbar.c file of the demo program package of this guide for the complete source code.
List 1 Use of cool bar control
Figure 1 Use of cool bar control
This program creates a tool bar comprised of “0-9” figures in a dialog box. When the user clicks the item in the toolbar, the corresponding figure is typed into the above edit box.
-- Main.XiaodongLi - 26 Oct 2009
<< | Table of Contents | >>
