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 Tech Support » Toolbar buttons with drop-down menus bug Collapse All
Subject Author Date
Neville Franks Apr 5, 2005 - 2:38 AM

Toolbar buttons with drop-down menus don’t have their menu disabled when the button is disabled. ie. Click on the drop own arrow and the menu is displayed even though the button is disabled.


In my CMainFrame::OnExtMenuPrepare() function I tried adding:


pData->m_bMenuCanceled = true;


but this causes an exception because m_pPopup is deleted twice.


Is there some way I can stop the menu from appearing when the button is disabled?

Technical Support Apr 5, 2005 - 10:40 AM

It’s not a bug at all. We believe that, if such a button is disabled, in all cases, displaying its pop-up menu should be disabled. For example, Microsoft Office applications do produce menus for disabled buttons (of course the items in such menus are reasonably disabled). But we agree with you that in some cases it would be better to disable producing such a menu at all (like Back and Forward buttons). Here is how it can be done.

Create a CExtBarButton-derived class and override the CanBePressedInDisabledState() virtual method which should do nothing except return false. Now you need to use this button in your toolbars. Create your own CExtToolControlBar-derived class and override the OnCreateBarCommandBtn() virtual method that creates a new instance of your button. Finally, if your application is customizable, please override the CExtCustomizeSite::OnUserBarCreate() virtual method. This method creates instances of your toolbar type. Use the method body from the original method and only modify the code responsible for creating this button.

Neville Franks Apr 26, 2005 - 7:40 PM

Thanks, that all works fine. Can I make a request though that a new flag be added to CExtBarButton that does this. That will save having to create a derived class and duplicate code.