Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

If you store the UI state in the registry, you can use the following code to load the paint manager's state:

CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );
ASSERT( pApp->m_pszRegistryKey != NULL );
ASSERT( pApp->m_pszRegistryKey[0] != _T('\0') );
ASSERT( pApp->m_pszProfileName != NULL );
ASSERT( pApp->m_pszProfileName[0] != _T('\0') );

if( ! g_PaintManager.PaintManagerStateLoad(
pApp->m_pszRegistryKey,
pApp->m_pszProfileName,
pApp->m_pszProfileName
)
)
g_PaintManager.InstallPaintManager(
RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_LunaBlue)
);

To initialize the application faster, load the paint manager's state before any window in your application is created. You can put the above code, for instance, into a constructor of the main frame or dialog window.

The code below saves the paint manager's state to the registry:

CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );
ASSERT( pApp->m_pszRegistryKey != NULL );
ASSERT( pApp->m_pszRegistryKey[0] != _T('\0') );
ASSERT( pApp->m_pszProfileName != NULL );
ASSERT( pApp->m_pszProfileName[0] != _T('\0') );

VERIFY(
g_PaintManager.PaintManagerStateSave(
pApp->m_pszRegistryKey,
pApp->m_pszProfileName,
pApp->m_pszProfileName
)
);

You can also serialize the paint manager's state to a CArchive using the PaintManagerStateSerialize() method.