Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » toolbar button with submenu Collapse All
Subject Author Date
Finn Arildsen Dec 19, 2004 - 3:16 PM

Is there a sample that illustrates how to handle a toolbar button with a submenu? 


What I would like to have is a toolbar button with a drop-down menu.


Thanks for your help


Finn

Technical Support Dec 20, 2004 - 2:20 AM

Dear Finn,

You can find a toolbar button with a pop-up menu in the DRAWCLI sample application. Here is how to implement it.


First of all, add a menu resource with one root pop-up item (its 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 the menu bar’s menu). 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), invoke the following methods after the button’s 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); 

Finn Arildsen Dec 21, 2004 - 3:11 PM

It works nicely.  Many thanks.  


Finn