Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

Show a menu when the drop down arrow of a 'split' toolbar button is clicked

 
Subscribe to the RSS feed for this forum  Forum Index -> EZNamespaceExtensionsMFC
View previous topic :: View next topic  
Author Message
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
// ...
// ...
}
}
Back to top
Display posts from previous:   
Forum Index -> EZNamespaceExtensionsMFC All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group