Where (what method) do you call Replace Button.
It should be done in the handler of AFX_WM_RESETTOOLBAR in the main frame.
this is what I do:
...
ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset)
...
LRESULT CMainFrame::OnToolbarReset(WPARAM wp,LPARAM)
{
UINT uiToolBarId = (UINT) wp;
TRACE( "CMainFrame::OnToolbarReset : %i\n", uiToolBarId );
switch (uiToolBarId)
{
case YOUR_TOOLBAR_ID:
CMFCToolBarComboBoxButton deviceCombo(IDC_DEVICE_TOOLBAR_COMBO, GetCmdMgr()->GetCmdImage(IDC_DEVICE_TOOLBAR_COMBO, FALSE), CBS_DROPDOWNLIST);
m_DeviceToolBar.ReplaceButton ( IDC_DEVICE_TOOLBAR_COMBO, deviceCombo );
break;
}
}
NOTE: the framework will save/load the state of the buttons of the toolbars in the registry, if you make changes to the code, the application will still use those values. so remove your application entry in the registry when (re)coding toolbars. This is quite aggravating.
Good luck.