You will need to use the state persistence of three Prof-UIS subsystems: customize site, control bars and command manager. Let us review all three systems:
1) The following methods of the CExtCustomizeSite
class can be used for implementing the state persistence of customization subsystem:
bool CustomizeStateLoad(
__EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USER\Software
__EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%
__EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%\%sSectionNameProfile%
HKEY hKeyRoot = HKEY_CURRENT_USER,
bool bEnableThrowExceptions = false
);
bool CustomizeStateSave(
__EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USER\Software
__EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%
__EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%\%sSectionNameProfile%\%sSectionNameProfile%
HKEY hKeyRoot = HKEY_CURRENT_USER,
bool bEnableThrowExceptions = false
);
virtual bool CustomizeStateSerialize(
CArchive & ar,
bool bEnableThrowExceptions = false
);
2) The following static methods of the
CExtControlBar
class can be used for implementing the state persistence of control bars created inside a frame window:
static bool ProfileBarStateLoad(
CFrameWnd * pFrame,
__EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USER\Software
__EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%
__EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%\%sSectionNameProfile%
LPWINDOWPLACEMENT pFrameWp = NULL, // need serialize frame’s WP
bool bSerializeFixedBarsState = true,
bool bSerializeResizableBarsState = true,
HKEY hKeyRoot = HKEY_CURRENT_USER,
bool bEnableThrowExceptions = false
);
static bool ProfileBarStateSave(
CFrameWnd * pFrame,
__EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USER\Software
__EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%
__EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%\%sSectionNameProfile%\%sSectionNameProfile%
LPWINDOWPLACEMENT pFrameWp = NULL, // need serialize frame’s WP
bool bSerializeFixedBarsState = true,
bool bSerializeResizableBarsState = true,
HKEY hKeyRoot = HKEY_CURRENT_USER,
bool bEnableThrowExceptions = false
);
static bool ProfileBarStateSerialize(
CArchive & ar,
CFrameWnd * pFrame,
LPWINDOWPLACEMENT pFrameWp = NULL, // need serialize frame’s WP
bool bSerializeFixedBarsState = true,
bool bSerializeResizableBarsState = true,
bool bEnableThrowExceptions = false
);
3) The following methods of the
CExtCmdManager
class can be used for implementing state persistence of the command manager:
bool SerializeState(
__EXT_MFC_SAFE_LPCTSTR sProfileName,
__EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USER\Software
__EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USER\Software\%sSectionNameCompany%
bool bSave,
HKEY hKeyRoot = HKEY_CURRENT_USER,
bool bEnableThrowExceptions = false
);
bool SerializeState(
__EXT_MFC_SAFE_LPCTSTR sProfileName,
CArchive & ar,
bool bEnableThrowExceptions = false
);
In all cases there are two types of methods: registry related methods and
CArchive
-based methods. The registry related methods are based on
CArchive
-based methods. So, you can serialize the state of each subsystem using a file on disk, a memory buffer or any other external data storage. The
StateInFile sample demonstrates how to implement the state persistence for control bars using a file on disk.
Both MFC and Prof-UIS require the exact match between the state data and the set of control bars created in the frame window. So, you can serialize the state of all the subsystems and add some data specific for your application which describes its UI version for detecting very strong improvements.