Command Bands

The command bands control is a special kind of rebar control. It has a fixed band at the top containing a toolbar with a Close (X) button, and optionally, a Help (?) button and an OK button, in the right corner. By default, each band in the command bands control contains a command bar. You can override this, however, if you want a band to contain some other type of child window.

Windows CE command band

    To create a command band control
  1. Initialize an INITCOMMONCONTROLSEX structure with (ICC_BAR_CLASSES | ICC_COOL_CLASSES) as the dwICC member.
  2. Register the command bands control class and the command bar class by calling the InitCommonControlsEx function, passing in the INITCOMMONCONTROLSEX structure.
  3. Create the image list to use for the band images.
  4. Create the commands bands control by calling the CommandBands_Create function, and then passing the image list handle in the himl parameter.
  5. Initialize an array of REBARBANDINFO structures, one for each band in the command bands control.
  6. Add the bands by calling the CommandBands_AddBands function, passing the array of REBARBANDINFO structures in the prbbi parameter.
  7. Add controls to the command bars in the bands by calling the appropriate command bar functions for the controls you want to add.
  8. Add the Close and Help buttons by calling the CommandBands_AddAdornments function. When you do this, the Close button is added by default.

The following code example demonstrates how to register a command band and command bar.

INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
InitCommonControlsEx(&icex);

HWND hwndCmdBands, hwnd;
REBARBANDINFO arbbi[2];

HIMAGELIST himl = ImageList_Create(16, 16, ILC_COLOR, 2, 0);
hwndCmdBands = CommandBands_Create(g_hinst, hwndParent, BANDS_ID, 
   RBS_VARHEIGHT | RBS_BANDBORDERS, himl);

arbbi[0].cbSize = sizeof(REBARBANDINFO); 
arbbi[0].fMask = RBBIM_ID | RBBIM_STYLE| RBBIM_SIZE |  RBBIM_IMAGE;
arbbi[0].fStyle = RBBS_NOGRIPPER ;
arbbi[0].wID = ID_MENUBAND;
arbbi[0].cx = 100;
arbbi[0].iImage = 0;

arbbi[1].cbSize = sizeof(REBARBANDINFO); 
arbbi[1].fMask = RBBIM_ID |  RBBIM_IMAGE | RBBIM_SIZE;
arbbi[1].wID = ID_BUTTONBAND;
arbbi[1].cx = 125;
arbbi[1].iImage = 1;

CommandBands_AddBands(hwndCmdBands, g_hinst, 2, arbbi);

hwnd = CommandBands_GetCommandBar(hwndCmdBands, 0);
CommandBar_InsertMenubar(hwnd, g_hinst, IDM_MAINMENU, 0);

hwnd = CommandBands_GetCommandBar(hwndCmdBands, 1);
CommandBar_AddBitmap(hwnd, HINST_COMMCTRL, IDB_STD_SMALL_COLOR, 0, 0, 0);
CommandBar_AddButtons(hwnd, sizeof(tbButtons)/sizeof(TBBUTTON), tbButtons);

CommandBands_AddAdornments(hwndCmdBands, g_hinst, CMDBAR_HELP, NULL);

Command bands controls support the custom draw service, which makes it easy to customize the appearance of a command bands control. For information on the custom draw service, see Overview of Controls.