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 » add special buttons dynamicly to customization subsystem Collapse All
Subject Author Date
Stephan Finkler Apr 24, 2006 - 10:19 AM

Hi,

I have got a derived class from CExtToolControlBar.
In this class there is a function to insert btns dynamicly.
e.g.
CMyToolBar::InsertBtn() {
....
// register new special character
if( nBtnCmdID >= nBtnCmdIDMin && nBtnCmdID <= nBtnCmdIDMax ) {
// register new cmd for btn
CExtCmdItem *pCmdItem = g_CmdManager->CmdAllocPtr( lpszProfileName, nBtnCmdID );
ASSERT( pCmdItem != NULL );
if( pCmdItem != NULL ) {
CString ToolTip = pSCBtn->m_SpecialChar.HexCode + _T(" ") + pSCBtn->m_SpecialChar.Description;
pCmdItem->m_sTipTool = ToolTip;
pCmdItem->m_sTipStatus = ToolTip;
pCmdItem->m_sToolbarText = pSCBtn->m_SpecialChar.cChar;
pCmdItem->m_sMenuText = pSCBtn->m_SpecialChar.cChar;

// add btn to toolbar
pSCBtn->SetCmdID(nBtnCmdID);
VERIFY( InsertButton( -1, ID_SEPARATOR) );
VERIFY( InsertSpecButton( -1, pSCBtn) );


Customization is enabled and the toolbar is registered.

How can I add the dynamicly created buttons to customization subsystem
(like in CExtCustomizeSite::OnRegisterToolBar)?

Thank for any help.
Michael



Technical Support Apr 25, 2006 - 11:30 AM

You should use a different approach when modifying customizable toolbar’s content because the toolbar is based on the CExtCustomizeCmdTreeNode tree-like data: get the active command tree node, change the array of its children and apply the modified node to the toolbar. Here is the sample code:

CExtCustomizeSite * pSite = . . .
CExtToolControlBar * pToolBar = . . .
CExtCustomizeCmdTreeNode * pRootNode = pSite->GetToolbarCmdNode( pToolBar, false );
    ASSERT_VALID( pRootNode );
    // modify pRootNode here
    pToolBar->RemoveAllNodes();
CExtCustomizeCmdTreeNode * pNewNode =
        new CExtCustomizeCmdTreeNode( . . . );
    pToolBar->InsertNode(
        pSite,
        pNewNode,
        nInsertPosition // -1 - append
        );
    . . .
    // update windows
    pToolBar->SetButtons( pRootNode );
    if( pToolBar->IsVisible() )
        pToolBar->GetParentFrame()->RecalcLayout();