Thank you for reporting this issue. We have successfully reproduced it in the DRAWCLI sample application where we added the following property into the CSplitFrame
class:
CExtToolControlBar m_wndNRTB; // non-redockable toolbar
We have created this toolbar in the following method and it really displayed unwanted
ID_EXT_CUSTOMIZE
menu command in the context menu over it:
int CSplitFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if( CExtNCW < CMDIChildWnd > :: OnCreate( lpCreateStruct ) == -1 )
return -1;
ASSERT( m_hChildFrameIcon != NULL );
SetIcon( m_hChildFrameIcon, FALSE );
SetIcon( m_hChildFrameIcon, TRUE );
VERIFY( m_wndNRTB.Create( NULL, this ) );
VERIFY( m_wndNRTB.LoadToolBar( IDR_MAINFRAME ) );
m_wndNRTB.m_bCustomizationAllowed = false;
return 0;
}
To fix this issue please update the source code for the following method:
bool CExtDockBar::_ConstructDockSiteControlBarPopupMenu(
CFrameWnd * pFrame,
CExtPopupMenuWnd * pPopup,
SHORT nHelperNotificationType,
CControlBar * pBarEventSrc,
UINT nMsgID, // = WM_NULL
CObject * pObjectSrc // = NULL
)
{
ASSERT_VALID( pFrame );
ASSERT( pPopup != NULL );
CExtControlBar::POPUP_MENU_EVENT_DATA _pmed(
nHelperNotificationType,
pPopup,
pBarEventSrc,
CPoint( -1, -1 ),
nMsgID,
pObjectSrc
);
bool bPreNotificationPassed = _pmed.NotifyTarget( false );
if( !bPreNotificationPassed )
{
ExtControlBarVector_t vBars;
CExtControlBar::_GetFrameControlBars(
NULL,
pFrame,
vBars
);
bool bOleInplaceItemActivated =
CExtControlBar::IsOleIpObjActive( pFrame );
int nBarsCount = (int)vBars.GetSize();
CExtControlBar * pPrevBar = NULL;
for( int i=0; i<nBarsCount; i++ )
{
CExtControlBar * pBar = vBars[i];
ASSERT_VALID( pBar );
if( pBar->GetSafeHwnd() == NULL
|| ( ! ::IsWindow(pBar->GetSafeHwnd()) )
)
continue;
// do not include dynamic bars
if( pBar->IsKindOf( RUNTIME_CLASS(CExtDynControlBar) ) )
continue;
// do not include temporary hidden bars
if( pBar->m_nStateFlags &
//(CControlBar::delayHide | CControlBar::tempHide)
CControlBar::tempHide
)
continue;
// do not include some bars when OLE inplace object active
if( bOleInplaceItemActivated &&
(pBar->m_dwStyle & CBRS_HIDE_INPLACE)
)
continue;
// do not include bars without caption
CString sBarText;
pBar->GetWindowText( sBarText );
if( sBarText.IsEmpty() )
{
// do not include bars without window text to menu
// ASSERT( FALSE );
continue;
}
if( pPrevBar != NULL
&&
pPrevBar->IsFixedDockStyle() != pBar->IsFixedDockStyle()
)
{
VERIFY(
pPopup->ItemInsert(
CExtPopupMenuWnd::TYPE_SEPARATOR
)
);
}
int nBarID = pBar->GetDlgCtrlID();
ASSERT( CExtCmdManager::IsCommand(nBarID) );
CExtCmdItem _cmd;
_cmd.m_nCmdID = nBarID;
_cmd.m_sMenuText = sBarText;
_cmd.TipsLoad();
g_CmdManager->CmdSetup(
g_CmdManager->ProfileNameFromWnd( pFrame->GetSafeHwnd() ),
_cmd
);
if( pBar->OnConstructDockSiteControlBarPopupMenu(pPopup) )
pPrevBar = pBar;
} // for( int i=0; i<nBarsCount; i++ )
} // if( !bPreNotificationPassed )
// remove double separators
INT nCount = pPopup->ItemGetCount();
for( INT nItem = 1; nItem < nCount; )
{
CExtPopupMenuWnd::MENUITEMDATA & _miiPrev =
pPopup->ItemGetInfo( nItem - 1 );
if( !_miiPrev.IsSeparator() )
{
nItem++;
continue;
}
CExtPopupMenuWnd::MENUITEMDATA & _miiCurr =
pPopup->ItemGetInfo( nItem );
if( !_miiCurr.IsSeparator() )
{
nItem++;
continue;
}
pPopup->ItemRemove( nItem );
nCount--;
} // for( INT nItem = 1; nItem < nCount; )
#if (!defined __EXT_MFC_NO_CUSTOMIZE)
bool bAddCustomizeCmd = false;
if( (!bPreNotificationPassed)
&& ( nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_CTX
|| nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NC_CTX
|| nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_DOCKBAR_CTX
|| nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_STATUSBAR_CTX
|| nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MINIFRAME_NC_CTX
)
&& CExtCustomizeSite::GetCustomizeSite( pBarEventSrc->GetSafeHwnd() ) != NULL
)
bAddCustomizeCmd = true;
if( bAddCustomizeCmd
&& pBarEventSrc->GetSafeHwnd() != NULL
&& pBarEventSrc->IsKindOf( RUNTIME_CLASS( CExtToolControlBar ) )
&& ( ! ((CExtToolControlBar*)pBarEventSrc)->m_bCustomizationAllowed )
)
bAddCustomizeCmd = false;
if( bAddCustomizeCmd )
{ // add customize command
LPCTSTR strCmdProfile = g_CmdManager->ProfileNameFromWnd( pFrame->m_hWnd );
if( strCmdProfile != NULL
&& g_CmdManager->CmdGetPtr( strCmdProfile, ID_EXT_CUSTOMIZE ) != NULL
)
{
// add tail separator
nCount = pPopup->ItemGetCount();
if( nCount > 0 )
{
CExtPopupMenuWnd::MENUITEMDATA & _mii =
pPopup->ItemGetInfo( nCount - 1 );
if( !_mii.IsSeparator() )
pPopup->ItemInsert();
} // if( nCount > 0 )
VERIFY( pPopup->ItemInsert( ID_EXT_CUSTOMIZE ) );
CExtPopupMenuWnd::MENUITEMDATA & mi =
pPopup->ItemGetInfo(
pPopup->ItemGetCount() - 1
);
mi.SetForceEnabled();
} // if( strCmdProfile != NULL ...
} // add customize command
#endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
_pmed.NotifyTarget( true );
// remove tail separator
nCount = pPopup->ItemGetCount();
if( nCount > 0 )
{
CExtPopupMenuWnd::MENUITEMDATA & _mii =
pPopup->ItemGetInfo( nCount - 1 );
if( _mii.IsSeparator() )
pPopup->ItemRemove( nCount - 1 );
} // if( nCount > 0 )
return true;
}