Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

First of all, add a menu resource with one root pop-up item (the text is unimportant). This menu will be used by the toolbar button. Please register this menu in the command manager by calling g_CmdManager->UpdateFromMenu() (similar to how you do this for a menu in the menu bar). After that, put the following lines after the code responsible for creating the toolbar:

INT nBtnIdx =
    m_wndToolBar.CommandToIndex(
        ID_BUTTON_FOR_MENU
    );
ASSERT( nBtnIdx >= 0 );
CMenu _menu;
VERIFY(
    _menu.LoadMenu(
        IDR_MENU_RESOURCE_FOR_BUTTON
    )
);
VERIFY(
    m_wndToolBar.SetButtonMenu(
        nBtnIdx,
        _menu.Detach()
    )
);

If you want the button face to be split into two parts (a drop-down button), call the following methods after the button menu is attached:

CExtBarButton * pTBB =
    m_wndToolBar.GetButton( nBtnIdx );
ASSERT_VALID( pTBB );
pTBB->SetSeparatedDropDown();

If you want your button to look in the vertically docked toolbar the same as it looks in the horizontally docked toolbar, call

pTBB->SetNoRotateVerticalLayout();

For the button with a drop-down arrow (a drop-down button), you may need to set the initially selected command:

pTBB->SetAutoChangeID();
pTBB->SetCmdID(ID_INITIALLY_SELECTED_COMMAND,true);