Configure a single zoneTranslation:Tellmenow
At this point, the command Belt control has been created, and a single zone has been added to the control. Next we have more tasks to do, that is, to configure separate command bar controls in each band. (In fact, configuring the command bar control is slightly more complex than the command bar described above .)
You can use the following function to obtain the command bar handle in a zone:
Hwnd commandbands_getcommandbar (hwnd hwndcmdbands, uint uband );
Ubnadis a zone-based 0 index that contains the command bar. When this function is called when the command Belt control is initialized, the index value is directly associated with the order in which the Belt control is added. However, once the user has the opportunity to drag the band to a new order, your application must send the rb_idtoindex message to the command Belt control to obtain the index value, as shown below:
Nindex = sendmessage (hwndcmdbands, rb_1_index, id_band, 0 );
This message is very important for management of the band, because many functions and messages need to use the band index to identify the band. The problem is that the index value is not fixed because the index value changes because the user moves the band. Do not expect the index value to be consistent. As a rule, do not blindly use the index value before you use rb_idtoindex to query the index value.
Once you get the command bar window handle and use the standard command bar control function and message, you can easily add the menu or button to the command bar. In most cases, add only menus in the first command bar, add only buttons in the second, and add other controls to the third and subsequent command lines.
The following code completes the creation process mentioned above. First, the command bar control in the first two zones is initialized. Because the third zone has an editing control, you do not need to initialize the zone. The last line of code is to call the commandbands_addadornments function to add the close button to the control.
// Add menu to first band.
Hwndband = commandbands_getcommandbar (hwndcb, 0 );
Commandbar_insertmenubar (hwndband, hinst, id_menu, 0 );
// Add standard buttons to second band.
Hwndband = commandbands_getcommandbar (hwndcb, 1 );
Commandbar_addbitmap (hwndband, hinst_commctrl, idb_std_small_color, 15, 0, 0 );
Commandbar_addbuttons (hwndband, dim (tbcbstdbtns), tbcbstdbtns );
// Add exit button to command band.
Commandbands_addadornments (hwndcb, hinst, 0, null );