Toll Free: (877) 723-1442 U.S. and Canada
Support
ActiveX / COM
Visual C++ / MFC
Customer Spotlight
Corporate Partners
Contact Sales

Call center available M-F 9:00 - 6:00 US Eastern Time.

U.S. and Canada
(877) 723-1442

International
(517) 625-5729

Email

Add a splitter popup button that doesn't disappear

Author: Kirk Stowell
Posted: November 16, 2004
Environment: Visual C++ MFC

If you have created a splitter popup button as shown below, it will disappear when the ‘Reset Toolbar’ button is clicked.

 pStandardBar->GetControls()->Add(xtpControlSplitButtonPopup, ID_BUTTON_POPUP);

If you use Customizable toolbars you must avoid dynamic creation of controls. You must use the ‘Xtreme Control Sub classing’ technique.  To add a splitter button do the following:

1. Add the button to your toolbar resource using the Visual Studio resource editor like so:

2. Using the resource editor, create a Popup menu with same command id as the toolbar button you just added.

3. Add the command handler ON_XTP_CREATECONTROL() to your CMainFrame message map.

 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)

 //{{AFX_MSG_MAP(CMainFrame)

 ...

 //}}AFX_MSG_MAP

 ON_XTP_CREATECONTROL()

 END_MESSAGE_MAP()

 

 int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)

 {

     if (lpCreateControl->bToolBar)

     {

         if (lpCreateControl->nID == ID_BUTTON_POPUP)

         {

             lpCreateControl->controlType = xtpControlSplitButtonPopup;

             return TRUE;

         }

     }

     return FALSE;

 }


4. Add the following line to your header file for CMainFrame:

 afx_msg int OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl);


Application screen shot showing splitter popup button:

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Other products and/or company names may be trademarks or registered trademarks of their respective owners.