here my code :
class CUI_ToolBar :
public CExtToolControlBar
{
public:
class CMyContentExpandButton : public CExtBarContentExpandButton
{
public:
CMyContentExpandButton( CExtToolControlBar * pBar = NULL )
: CExtBarContentExpandButton( pBar )
{
}
virtual bool IsVisible() const
{
bool bVisible = ( GetButtons().GetSize() > 0 ) ? true : false;
return bVisible;
}
};
CUI_ToolBar(void);
virtual CExtBarContentExpandButton * OnCreateBarRightBtn()
{
return new CMyContentExpandButton( this );
}
virtual ~CUI_ToolBar(void);
virtual void _RecalcPositionsImpl()
{
CExtToolControlBar::_RecalcPositionsImpl();
if( m_pDockBar != NULL )
{
return;
}
CExtBarContentExpandButton * pRightTBB = GetRightButton();
if( pRightTBB == NULL )
{
return;
}
if( ! pRightTBB->IsVisible() )
{
return;
}
bool bHorz = ((GetBarStyle()&(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM))!=0) ? true : false;
CRect rcRightTBB = *pRightTBB, rcClient;
GetClientRect( &rcClient );
rcRightTBB.OffsetRect(
bHorz ? ( rcClient.right - rcRightTBB.right ) : 0,
bHorz ? 0 : ( rcClient.bottom - rcRightTBB.bottom )
);
pRightTBB->SetRect( rcRightTBB );
INT nIndex, nCount = GetButtonsCount();
for( nIndex = 0; nIndex < nCount; nIndex ++ )
{
CExtBarButton * pTBB = GetButton( nIndex );
if( ! pTBB->IsVisible() )
{
continue;
}
if( pTBB == pRightTBB )
{
continue;
}
CRect rcTBB = *pTBB;
if( bHorz )
{
if( rcTBB.right < rcRightTBB.left )
{
continue;
}
}
else
{
if( rcTBB.bottom < rcRightTBB.top )
{
continue;
}
}
pTBB->Show( false );
pRightTBB->GetButtons().InsertAt( 0, pTBB );
}
}
//virtual CExtBarButton * OnCreateBarCommandBtn(UINT nCmdID, UINT nStyle = 0);
};
in the mainframe :
int CUI_MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
if( !this->m_ToolBar_File.Create(
NULL,
this,
AFX_IDW_TOOLBAR
)
||
!this->m_ToolBar_File.LoadToolBar( IDR_TOOLBAR_FILE)
)
{
TRACE0("Failed to create toolbar file\n");
return -1; // fail to create
}
...
m_ToolBar_File.EnableDocking( CBRS_ALIGN_ANY );
DockControlBar( &m_ToolBar_File);
..
}
When I debug this code, it stop and exist on the line :
if( m_pDockBar != NULL )
{
return;
}
If I comment the lines, and replace the for( nIndex = 0; nIndex < nCount; nIndex ++ ) with
for( nIndex = 0; nIndex < nCount; nIndex ++ )
{
CExtBarButton * pTBB = GetButton( nIndex );
pRightTBB->GetButtons().InsertAt( 0, pTBB );
}
When I click on the chevron no menu will be visible. Have you got an idea ?