I store (re-) the states of my dockable toolbars by means of
SaveBarState (load-) in OnClose (OnCreate).
With 2 toolbars there was no problem. But after adding a 3rd one
restored positions were wrong(ID'S of toolbars are different, VC++6.0)!
I think the registry entries which have been saved by SaveBarState are
wrong because e.g. BarID=53369 although it should be 109.
Did anyone else experience this problem?
Thanks in advance!
>I store (re-) the states of my dockable toolbars by means of
>SaveBarState (load-) in OnClose (OnCreate).
>
>With 2 toolbars there was no problem. But after adding a 3rd one
>restored positions were wrong(ID'S of toolbars are different, VC++6.0)!
>
>I think the registry entries which have been saved by SaveBarState are
>wrong because e.g. BarID=53369 although it should be 109.
Insert this function, to ignore the invalid serialized toolbardockstate.
PS. This function helps to avoid GPF during CFrameWnd::SetDockState execution:
when one of the previously saved toolbars is not created, SetDockState fails.
BOOL CMainFrame::IsDockStateValid (const CDockState& state)
{
for (int i = 0; i < state.m_arrBarInfo.GetSize (); i ++)
{
CControlBarInfo* pInfo = (CControlBarInfo*) state.m_arrBarInfo [i];
ASSERT (pInfo != NULL);
if (!pInfo->m_bFloating)
{
//---------------------------------------
// Find the control bar with the same ID:
//---------------------------------------
if (GetControlBar (pInfo->m_nBarID) == NULL)
{
TRACE (_T("IsDockStateValid ControlBar %x(%d) is not valid!\n"),
pInfo->m_nBarID,pInfo->m_nBarID);
return FALSE;
}
}
}
return TRUE; //all states are valid
}
CMainFrame::OnCreate(...)
{
//Create toolbar's
...
CDockState state;
state.LoadState("Toolbar");
if(IsDockStateValid(state))
SetDockState(state);
}
Gruss
Andreas
--
a.brachold@_REMOVE_THIS_cityweb.de
For direct mail reply remove _REMOVE_THIS_