As for this program, ToolBar changes dynamically.
Programs always hold Window handles of the control that they made in array first
I assign it to ToolBar as needed.
static CExtButton m_Btn1;
m_Btn1.Create( "button control" ,
WS_CHILD|WS_VISIBLE
|BS_PUSHBUTTON
|BS_VCENTER
|BS_AUTOCHECKBOX
|BS_PUSHLIKE
,
CRect(0,0, 60,20), &m_wndInnerBar, IDS_BUTTON1 );
m_Btn1.SetDrawBorder ( TRUE );
m_Btn1.SetTextColorNormal ( COLORREF(RGB(0,0,0)) );
m_wndInnerBar.AddCtrlID( IDS_BUTTON1 );
However, from 2.87 in SetButtons of the bar, DestroyWindow of the control runs.
I do not want to work in DestroyWindow and delete of the control
void CExtBarButton::CtrlSet(
CWnd * pCtrl,
bool bCtrlAutoDestroyed
)
{
ASSERT_VALID( this );
if( m_pCtrl != NULL )
{
if( ::IsWindow(m_pCtrl->GetSafeHwnd()) )
m_pCtrl->DestroyWindow();
if( ! m_bCtrlAutoDestroyed )
delete m_pCtrl;
}
m_pCtrl = pCtrl;
m_bCtrlAutoDestroyed = bCtrlAutoDestroyed;
#ifdef _DEBUG
if( m_pCtrl != NULL )
{
ASSERT_VALID( m_pCtrl );
}
#endif // _DEBUG
}