Guides & Tutorials (beta)

Add a splitter popup button that doesn't disappear

by Kirk Stowell Visual C++ Created on 11/16/2007  |  Updated on 07/30/2024 0/5 ( 0 votes )

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 ‘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:

Splitter Button

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:

Splitter Button

User Comments

No comments yet, sign in to comment.

Secure Transactions

Online transactions are secure and protected.


Ssl seal 1
This site is protected by Trustwave's Trusted Commerce program
CompliAssure Secured

Money Back Guarantee

If you are not 100% happy with your purchase within 30 days, you can return it for any reason. Your satisfaction is our priority!


Satisfication Guarantee

Contact sales@codejock.com for more details.