|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Timo Stripf
|
Oct 17, 2009 - 7:39 AM
|
Hi, i have a SDI Application with DynamicControlBars on it. When i save and restore the state of it, then i get a non ordered tabpagecointer.
Example
Page 1 | Page 2 | Page 3
now i drag Page1 after Page3
Page 2 | Page 3 | Page 1
when i save this state and restart the application is the order the same as before. The same problem is, when i close a tab and restore it over the menu or with OnCmdMsgOnBar, then it is not on the same position.
Is this with intent or is a problem of the framework himself?
|
|
Technical Support
|
Oct 26, 2009 - 2:18 PM
|
If all the windows inside a tab page container of your SDI application are resizable bars, then Prof-UIS can identify the selected tab page and restore it on restart. But Prof-UIS assumes the tab page container may contain page windows which are not related to the dynamic resizable control bars switched into the tabbed document mode. The same problem exists in the MDI environment with the dynamic resizable control bars. That’s why we didn’t implemented the selection persistence in the tab page container. We can implement it, but only in the particular case when there are no tab pages which are not dynamic bars. The 100% working solution for all the types of tab pages is to save/restore the selected page index in scope of your project’s code.
|
|
Timo Stripf
|
Oct 25, 2009 - 1:26 PM
|
Thanks for the great fix, but the Problem is not fixed completly. The sort works perfekt now, but the selected tab is not the same, after restart. I think it is better to see the same overview after every restart. I can save it by myself, but i think, it is better if the framework support it by default. Is the same procedure like visual studio.
|
|
Technical Support
|
Oct 20, 2009 - 9:48 AM
|
Thank you for reporting us this issue. To fix it, please update the source code for the following method:
bool CExtDynamicBarSite::StateSerialize(
CArchive & ar,
bool bEnableThrowExceptions // = false
)
{
ASSERT( this != NULL );
DWORD dwGeneralFlags = 0;
DWORD dwReserved = 0L;
try
{
if( ar.IsStoring() )
{
ar << dwGeneralFlags;
ar << dwReserved;
ar << dwReserved;
ar << dwReserved;
ar << dwReserved;
DWORD dwCount = (DWORD)BarEnumGetCount();
ar << dwCount;
POSITION pos = BarEnumGetStartPosition();
for( ; pos != NULL; )
{
CExtDynamicControlBar * pBar =
BarEnumGetNext( pos );
ASSERT_VALID( pBar );
bool bVisibleState = false;
if( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT )
{
if( bVisibleState )
{
ASSERT( m_listBarsInDocMode.Find( pBar ) != NULL );
continue;
}
}
ASSERT( m_listBarsInDocMode.Find( pBar ) == NULL );
UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
ar << DWORD(nCmdID);
bool bPersistentBar = pBar->IsPersistentBar();
DWORD dwSerializeFlags = 0;
if( bPersistentBar )
dwSerializeFlags |= 0x01;
ar << dwSerializeFlags;
if( ! bPersistentBar )
{
CRuntimeClass * pRTC = pBar->GetRuntimeClass();
ASSERT( pRTC != NULL );
ar.WriteClass( pRTC );
} // if( ! bPersistentBar )
ar << pBar->m_strCaptionText;
pBar->m_icon.Serialize( ar );
pBar->OnSerializeDynamicProps( ar );
} // for( ; pos != NULL; )
CTypedPtrList < CPtrList, CExtDynamicControlBar * > _listSerialize;
bool bUseDefaultOrder = true;
CExtDynamicBarSite::eDetectedUiType_t eDUIT = GetDetectedUiType();
eDUIT;
#if (!defined __EXT_MFC_NO_TABMDI_CTRL)
if( eDUIT == __EDUIT_MDI_WITH_TABS )
{ // detect MDI order using tabs
CExtTabWnd * pTabs = GetMdiTabs();
if( pTabs != NULL )
{
LONG nIndex, nCount = pTabs->ItemGetCount();
for( nIndex = 0L; nIndex < nCount; nIndex ++ )
{
HWND hWnd = (HWND)pTabs->ItemGet( nIndex )->LParamGet();
CWnd * pWndPremanent = CWnd::FromHandlePermanent( hWnd );
if( pWndPremanent == NULL )
continue;
CExtDynamicMDIChildWnd * pWndMdiChild = DYNAMIC_DOWNCAST( CExtDynamicMDIChildWnd, pWndPremanent );
if( pWndMdiChild == NULL )
continue;
if( pWndMdiChild->GetBarSite() != this )
continue;
CExtDynamicControlBar * pBar = pWndMdiChild->GetBar();
if( pBar == NULL )
continue;
if( m_listBarsInDocMode.Find( pBar ) == NULL )
continue;
_listSerialize.AddTail( pBar );
} // for( nIndex = 0L; nIndex < nCount; nIndex ++ )
if( _listSerialize.GetCount() == m_listBarsInDocMode.GetCount() )
bUseDefaultOrder = false;
else
_listSerialize.RemoveAll();
} // if( pTabs != NULL )
} // detect MDI order using tabs
#endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
#if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
if( eDUIT == __EDUIT_SDI_TAB_PAGE_CONTAINER )
{ // detect document mode order using SDI tab page container
CExtTabPageContainerWnd * pWndTabPageContainer = GetTabPageContainer();
if( pWndTabPageContainer->GetSafeHwnd() != NULL )
{
ASSERT_VALID( pWndTabPageContainer );
CTypedPtrList < CPtrList, CExtDynamicControlBar * > _listFound;
INT nIndex = 0, nCount = pWndTabPageContainer->PageGetCount();
for( nIndex = 0; nIndex < nCount; nIndex ++ )
{
HWND hWndPage = pWndTabPageContainer->PageHwndGetSafe( nIndex );
if( hWndPage == NULL )
continue;
CExtDynamicControlBar * pBar = BarFindByChildHWND( hWndPage );
if( pBar == NULL )
continue;
ASSERT_VALID( pBar );
#ifdef _DEBUG
bool bVisibleState = false;
ASSERT( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT );
ASSERT( bVisibleState );
#endif // _DEBUG
if( m_listBarsInDocMode.Find( pBar ) == NULL )
continue;
_listSerialize.AddTail( pBar );
}
if( _listSerialize.GetCount() == m_listBarsInDocMode.GetCount() )
bUseDefaultOrder = false;
else
_listSerialize.RemoveAll();
}
} // detect document mode order using SDI tab page container
#endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
if( bUseDefaultOrder )
_listSerialize.AddTail( &m_listBarsInDocMode );
//pos = m_listBarsInDocMode.GetTailPosition();
pos = _listSerialize.GetTailPosition();
for( ; pos != NULL; )
{
//CExtDynamicControlBar * pBar = m_listBarsInDocMode.GetPrev( pos );
CExtDynamicControlBar * pBar = _listSerialize.GetPrev( pos );
ASSERT_VALID( pBar );
ASSERT( pBar->BarStateGet() == CExtDynamicControlBar::__EDBS_DOCUMENT );
UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
ar << DWORD(nCmdID);
bool bPersistentBar = pBar->IsPersistentBar();
DWORD dwSerializeFlags = 0;
if( bPersistentBar )
dwSerializeFlags |= 0x01;
ar << dwSerializeFlags;
if( ! bPersistentBar )
{
CRuntimeClass * pRTC = pBar->GetRuntimeClass();
ASSERT( pRTC != NULL );
ar.WriteClass( pRTC );
} // if( ! bPersistentBar )
ar << pBar->m_strCaptionText;
pBar->m_icon.Serialize( ar );
pBar->OnSerializeDynamicProps( ar );
} // for( ; pos != NULL; )
} // if( ar.IsStoring() )
else
{
ar >> dwGeneralFlags;
ar >> dwReserved;
ar >> dwReserved;
ar >> dwReserved;
ar >> dwReserved;
BarFreeAll( false, true );
m_listBarsInDocMode.RemoveAll();
ASSERT( BarEnumGetCount( false, true ) == 0 );
DWORD dwCount;
ar >> dwCount;
for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++ )
{
UINT nCmdID;
DWORD dwTmp;
ar >> dwTmp;
nCmdID = UINT(dwTmp);
DWORD dwSerializeFlags;
ar >> dwSerializeFlags;
CExtDynamicControlBar * pBar = NULL;
if( (dwSerializeFlags & 0x01) != 0 )
{ // if serializing persistent bar
pBar = BarGetByCmdID( nCmdID );
if( pBar == NULL )
{
ASSERT( FALSE );
BarFreeAll( false, true );
#if _MFC_VER >= 0x0800
::AfxThrowArchiveException( CArchiveException::genericException );
#else
::AfxThrowArchiveException( CArchiveException::generic );
#endif
} // if( pBar == NULL )
ASSERT_VALID( pBar );
ar >> pBar->m_strCaptionText;
pBar->m_icon.Serialize( ar );
} // if serializing persistent bar
else
{ // if serializing dynamic bar
CRuntimeClass * pRTC = ar.ReadClass();
ASSERT( pRTC != NULL );
CExtSafeString strCaptionText;
ar >> strCaptionText;
CExtCmdIcon icon;
icon.Serialize( ar );
pBar =
BarAlloc(
strCaptionText,
icon,
nCmdID,
pRTC
);
if( pBar == NULL )
{
ASSERT( FALSE );
BarFreeAll( false, true );
#if _MFC_VER >= 0x0800
::AfxThrowArchiveException( CArchiveException::genericException );
#else
::AfxThrowArchiveException( CArchiveException::generic );
#endif
} // if( pBar == NULL )
} // if serializing dynamic bar
ASSERT_VALID( pBar );
pBar->OnSerializeDynamicProps( ar );
} // for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++ )
ASSERT( ((DWORD)BarEnumGetCount()) == dwCount );
} // else from if( ar.IsStoring() )
return true;
} // try
catch( CException * pException )
{
if( bEnableThrowExceptions )
throw;
pException->Delete();
} // catch( CException * pException )
catch( ... )
{
if( bEnableThrowExceptions )
throw;
} // catch( ... )
dwGeneralFlags;
dwReserved;
return false;
}
|
|
Timo Stripf
|
Oct 25, 2009 - 1:27 PM
|
Thanks for the great fix, but the Problem is not fixed completly. The sort works perfekt now, but the selected tab is not the same, after restart. I think it is better to see the same overview after every restart. I can save it by myself, but i think, it is better if the framework support it by default. Is the same procedure like visual studio.
|
|