How to prevent a disabled drop-down button from displaying a pop-up menu associated with it?

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

Although in many cases to disable only menu items in the pop-up menu seems to be more preferable (e.g., drop-down buttons in Microsoft Office applications), there is no doubt that in some cases it is reasonable to disable producing such a menu at all (like Back and Forward buttons in Internet browsers). Below is described 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 modify only the code responsible for creating this button.