Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Tue Jun 23, 2009 9:49 am Post subject: Show a menu when the drop down arrow of a 'split' toolbar button is clicked |
|
|
To add a split drop down button to the toolbar, override the CNSEFolder::GetToolbarButtons method and use following sample code:
Code: | void CKeyItem::GetToolbarButtons(CPtrList& buttons)
{
buttons.AddTail(new CShellToolbarButton(_T("Dropdown Button"),NSESTBT_SplitDropDown));
} |
To show a menu when the drop down arrow of a 'split' toolbar button is clicked, override the CNSEFolder::OnExecuteFrameCommand method and use the following code:
Code: | void CKeyItem::OnExecuteFrameCommand(CExecuteFrameCommandEventArgs& e)
{
if (CUtils::IsToolbarButtonDropDownAreaClicked(this))
{
// create and add some menu items
CMenu menu;
menu.CreatePopupMenu();
menu.AppendMenu(0,0,_T("Menu Item 1"));
menu.AppendMenu(0,1,_T("Menu Item 2"));
// Get position where menu should be shown
RECT rc = CUtils::GetClickedToolbarButtonBounds(this);
// create dummy window
HWND dummy = ::CreateWindow(_T("Static"),_T(""),WS_POPUP,0,0,0,0,NULL,NULL,NULL,NULL);
// show menu
int cmd = menu.TrackPopupMenu(TPM_RETURNCMD ,rc.left,rc.bottom,CWnd::FromHandle(dummy));
// destroy dummy window
DestroyWindow(dummy);
// Perform actions as per selected command
// ...
// ...
}
}
|
|
|