📄 bcgpworkspace.cpp
字号:
ASSERT_VALID (g_pSkinManager);
return g_pSkinManager;
}
#endif
CBCGPUserToolsManager* CBCGPWorkspace::GetUserToolsManager()
{
return g_pUserToolsManager;
}
//*************************************************************************************
CString CBCGPWorkspace::GetRegSectionPath(LPCTSTR szSectionAdd /*=NULL*/)
{
CString strSectionPath = ::BCGPGetRegPath (m_strRegSection);
if (szSectionAdd != NULL && _tcslen (szSectionAdd) != 0)
{
strSectionPath += szSectionAdd;
strSectionPath += _T("\\");
}
return strSectionPath;
}
//*************************************************************************************
BOOL CBCGPWorkspace::LoadState (LPCTSTR lpszSectionName /*=NULL*/, CBCGPFrameImpl* pFrameImpl /*= NULL*/)
{
if (lpszSectionName != NULL)
{
m_strRegSection = lpszSectionName;
}
CString strSection = GetRegSectionPath ();
//-----------------------------
// Other things to do before ?:
//-----------------------------
PreLoadState();
//------------------------
// Loaded library version:
//------------------------
CBCGPRegistrySP regSP;
CBCGPRegistry& reg = regSP.Create (FALSE, TRUE);
if (reg.Open (GetRegSectionPath (strRegEntryVersion)))
{
reg.Read (strVersionMajorKey, m_iSavedVersionMajor);
reg.Read (strVersionMinorKey, m_iSavedVersionMinor);
}
//--------------------------------------
// Save general toolbar/menu parameters:
//--------------------------------------
CBCGPToolBar::LoadParameters (strSection);
CMD_MGR.LoadState (strSection);
BOOL bResetImages = FALSE; // Reset images to default
if (m_bResourceSmartUpdate)
{
CBCGPToolbarButton::m_bUpdateImages = FALSE;
}
if (pFrameImpl != NULL)
{
//-------------------
// Load rebars state:
//-------------------
#ifndef BCG_NO_REBAR
CBCGPRebarState::LoadState (strSection, pFrameImpl->m_pFrame);
#endif
//-----------------------------------------------------
// Load all toolbars, menubar and docking control bars:
//-----------------------------------------------------
for (POSITION posTlb = gAllToolbars.GetHeadPosition (); posTlb != NULL;)
{
CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (posTlb);
ASSERT (pToolBar != NULL);
if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
{
ASSERT_VALID(pToolBar);
if (!m_bLoadSaveFrameBarsOnly ||
pToolBar->GetTopLevelFrame () == pFrameImpl->m_pFrame)
{
if (!pToolBar->IsFloating ())
{
pToolBar->LoadState (strSection);
if (pToolBar->IsResourceChanged ())
{
bResetImages = TRUE;
}
}
}
}
}
//----------------------------
// Load user defined toolbars:
//----------------------------
pFrameImpl->LoadUserToolbars ();
//------------------------
// Load tear-off toolbars:
//------------------------
pFrameImpl->LoadTearOffMenus ();
CDockState dockState;
dockState.LoadState(m_strRegSection + strRegEntryNameControlBars);
if (m_bForceDockStateLoad || pFrameImpl->IsDockStateValid (dockState))
{
if((GetDataVersionMajor() !=-1) && (GetDataVersionMinor() !=-1))
{
pFrameImpl->LoadDockState (strSection);
pFrameImpl->SetDockState (dockState); // By Sven Ritter
}
}
}
//--------------------------------------
// Load mouse/keyboard/menu managers:
//--------------------------------------
if (g_pMouseManager != NULL)
{
g_pMouseManager->LoadState (strSection);
}
if (g_pContextMenuManager != NULL)
{
g_pContextMenuManager->LoadState(strSection);
}
if (g_pKeyboardManager != NULL)
{
g_pKeyboardManager->LoadState (strSection,
pFrameImpl == NULL ? NULL : pFrameImpl->m_pFrame);
}
if (g_pUserToolsManager != NULL)
{
g_pUserToolsManager->LoadState (strSection);
}
#if defined _AFXDLL && !defined _BCGCBPRO_STATIC_ // Skins manager can not be used in the static version
if (g_pSkinManager != NULL)
{
g_pSkinManager->LoadState (strSection);
}
#endif
if (m_bResourceSmartUpdate)
{
CBCGPToolbarButton::m_bUpdateImages = TRUE;
}
if (m_bForceImageReset || (m_bResourceSmartUpdate && bResetImages))
{
for (POSITION posTlb = gAllToolbars.GetHeadPosition (); posTlb != NULL;)
{
CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (posTlb);
ASSERT (pToolBar != NULL);
if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
{
ASSERT_VALID (pToolBar);
pToolBar->ResetImages ();
}
}
if (pFrameImpl != NULL)
{
ASSERT_VALID (pFrameImpl->m_pFrame);
pFrameImpl->m_pFrame->RecalcLayout ();
}
}
//----------
// Call Hook
//----------
LoadCustomState();
//----------------------------------------------------------------------
// To not confuse internal serialization, set version number to current:
//----------------------------------------------------------------------
m_iSavedVersionMajor = _BCGCBPRO_VERSION_MAJOR;
m_iSavedVersionMinor = _BCGCBPRO_VERSION_MINOR;
return TRUE;
}
//*************************************************************************************
BOOL CBCGPWorkspace::LoadState (CBCGPMDIFrameWnd* pFrame, LPCTSTR lpszSectionName /*=NULL*/)
{
ASSERT_VALID (pFrame);
return LoadState (lpszSectionName, &pFrame->m_Impl);
}
//*************************************************************************************
BOOL CBCGPWorkspace::LoadState (CBCGPFrameWnd* pFrame, LPCTSTR lpszSectionName /*=NULL*/)
{
ASSERT_VALID (pFrame);
return LoadState (lpszSectionName, &pFrame->m_Impl);
}
//***********************************************************************************
BOOL CBCGPWorkspace::LoadState (CBCGPOleIPFrameWnd* pFrame, LPCTSTR lpszSectionName /*=NULL*/)
{
ASSERT_VALID (pFrame);
return LoadState (lpszSectionName, &pFrame->m_Impl);
}
//*************************************************************************************
BOOL CBCGPWorkspace::CleanState (LPCTSTR lpszSectionName /*=NULL*/)
{
if (lpszSectionName != NULL)
{
m_strRegSection = lpszSectionName;
}
CString strSection = GetRegSectionPath ();
CBCGPRegistrySP regSP;
CBCGPRegistry& reg = regSP.Create (FALSE, FALSE);
return reg.DeleteKey(strSection);
}
//*************************************************************************************
BOOL CBCGPWorkspace::SaveState (LPCTSTR lpszSectionName /*=NULL*/, CBCGPFrameImpl* pFrameImpl /*= NULL*/)
{
if (!m_bSaveState)
{
return FALSE;
}
if (lpszSectionName != NULL)
{
m_strRegSection = lpszSectionName;
}
CString strSection = GetRegSectionPath ();
//-----------------------------
// Other things to do before ?:
//-----------------------------
PreSaveState();
//----------------------
// Save library version:
//----------------------
CBCGPRegistrySP regSP;
CBCGPRegistry& reg = regSP.Create (FALSE, FALSE);
if (reg.CreateKey (GetRegSectionPath (strRegEntryVersion)))
{
reg.Write (strVersionMajorKey, _BCGCBPRO_VERSION_MAJOR);
reg.Write (strVersionMinorKey, _BCGCBPRO_VERSION_MINOR);
}
//--------------------------------------
// Save general toolbar/menu parameters:
//--------------------------------------
CBCGPToolBar::SaveParameters (strSection);
CMD_MGR.SaveState (strSection);
if (pFrameImpl != NULL)
{
CDockState dockState;
pFrameImpl->m_pFrame->GetDockState (dockState);
dockState.SaveState (m_strRegSection + strRegEntryNameControlBars);
pFrameImpl->SaveDockState (strSection);
//-----------------------------------------------------
// Save all toolbars, menubar and docking control bars:
//-----------------------------------------------------
for (POSITION posTlb = gAllToolbars.GetHeadPosition (); posTlb != NULL;)
{
CBCGPToolBar* pToolBar = (CBCGPToolBar*) gAllToolbars.GetNext (posTlb);
ASSERT (pToolBar != NULL);
if (CWnd::FromHandlePermanent (pToolBar->m_hWnd) != NULL)
{
ASSERT_VALID(pToolBar);
if (!m_bLoadSaveFrameBarsOnly ||
pToolBar->GetTopLevelFrame () == pFrameImpl->m_pFrame)
{
pToolBar->SaveState (strSection);
}
}
}
//----------------------------
// Save user defined toolbars:
//----------------------------
pFrameImpl->SaveUserToolbars (m_bLoadSaveFrameBarsOnly);
//------------------------
// Save tear-off toolbars:
//------------------------
pFrameImpl->SaveTearOffMenus (m_bLoadSaveFrameBarsOnly);
//-------------------
// Save rebars state:
//-------------------
#ifndef BCG_NO_REBAR
CBCGPRebarState::SaveState (strSection, pFrameImpl->m_pFrame);
#endif
}
//------------------
// Save user images:
//------------------
if (CBCGPToolBar::m_pUserImages != NULL)
{
ASSERT_VALID (CBCGPToolBar::m_pUserImages);
CBCGPToolBar::m_pUserImages->Save ();
}
//--------------------------------------
// Save mouse/keyboard/menu managers:
//--------------------------------------
if (g_pMouseManager != NULL)
{
g_pMouseManager->SaveState (strSection);
}
if (g_pContextMenuManager != NULL)
{
g_pContextMenuManager->SaveState (strSection);
}
if (g_pKeyboardManager != NULL)
{
g_pKeyboardManager->SaveState (strSection,
pFrameImpl == NULL ? NULL : pFrameImpl->m_pFrame);
}
if (g_pUserToolsManager != NULL)
{
g_pUserToolsManager->SaveState (strSection);
}
#if defined _AFXDLL && !defined _BCGCBPRO_STATIC_ // Skins manager can not be used in the static version
if (g_pSkinManager != NULL)
{
g_pSkinManager->SaveState (strSection);
}
#endif
SaveCustomState();
return TRUE;
}
//*************************************************************************************
// Overidables for customization
void CBCGPWorkspace::OnClosingMainFrame (CBCGPFrameImpl* pFrame)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -