Toolbars

A toolbar is a control that contains buttons. The buttons in a toolbar usually correspond to items on the application's menu, providing a quick way for the user to access these commands. When a user taps a toolbar button with the stylus, the toolbar sends the command message associated with the button to the toolbar's parent window. The Windows CE alternative to the toolbar is the command bar. A command bar combines a menu bar and a toolbar in a single control, which conserves limited screen space.

    

Windows CE toolbar

You create a toolbar by using the CreateToolbarEx function. Windows CE registers this class when it loads the common control DLL. You can use the InitCommonControls function to ensure that this DLL is loaded. To register the toolbar class using the InitCommonControlsEx function, specify the ICC_BAR_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure you pass in the lpInitCtrls parameter. You can also use the CreateWindowEx function to register the toolbar class by specifying the TOOLBARCLASSNAME window class. However, this method creates a toolbar that initially contains no buttons. You can then add buttons to the toolbar by using the TB_ADDBUTTONS or TB_INSERTBUTTON message.

A toolbar must be created as a child window with the WS_CHILD style. If you use CreateWindowEx to create a toolbar, you must specify the WS_CHILD window style. CreateToolbarEx includes the WS_CHILD style by default. You must specify the initial parent window when creating the toolbar, but you can change the parent window after creation by using the TB_SETPARENT message.

Windows CE does not support user customization of toolbars, or drag-and-drop operations for toolbars.