Your browser doesn't support JavaScript Creating a Toolbar - Windows Programming

Creating a Toolbar

Toolbars can be created using the CreateWindowEx function, specifying TOOLBARCLASSNAME as the window class name, or by using the depreciated API CreateToolbarEx function. A TBBUTTON structure contains information about the individual buttons and this is added to the toolbar via the sendmessage() function using the TB_ADDBUTTONS or TB_INSERTBUTTON message parameters. A bitmap is used to hold the toolbar image. Each time a button is clicked a WM command message will be generated with the ID of each button being held in the low order word of the wparam.

In the following example, a simple 3-button toolbar is defined and created with two standard buttons divided by a separator. A separator provides a small gap between button groups and does not receive user input. The API function LoadImage loads the toolbar bitmap from the local c drive into a handle of type HBITMAP. The toolbar image bitmap is then created by a call to the function ImageList_Create() and the imagelist is then added to the toolbar control by the function ImageList_Add(). The individual image associated with the toolbar button is set in the TBBUTTON structure.  Clicking either of these buttons will generate a message box indicating the button clicked

For in-depth reading on the creation of toolbars
https://docs.microsoft.com/en-us/windows/win32/controls/toolbar-control-reference

The following short program creates a simple toolbar with two buttons using the following two images. Clicking either button will produce a message box.