Professional UI Solutions
Site Map   /  Register
 
 

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.

Forums » Prof-UIS Tech Support » No Persistance of the selected Theme Collapse All
Subject Author Date
Alexander Kool Aug 11, 2006 - 9:45 AM

I have included the CExtThemeSwitcherToolControlBar and the switching between themes works fine.

Now I would expect that the selected theme is rememberd in the registry (it actually looks like it does that).
However on startup, the default theme is always initialized with the call to

g_PaintManager.InstallPaintManager(RUNTIME_CLASS( CExtPaintManagerStudio2005 );

Is there a way to use the saved setting?


Also, I noted that the Theme code seems to be is undocumented.



Alexander Kool

Technical Support Aug 14, 2006 - 6:38 AM

You can serialize the run-time class information of the currently installed paint manager using the following code:

// SAVE STATE
CExtPaintManager * pPM = g_PaintManager.GetPM();
CRuntimeClass * pRTC = pPM->GetRuntimeClass();
CFile file( . . . );
CArchive ar( &file, CArchive::store );
ar.WriteClass( pRTC );
 
// LOAD STATE
CFile file( . . . );
CArchive ar( &file, CArchive::load );
CRuntimeClass * pRTC = ar.ReadClass( pRTC );
g_PaintManager.InstallPaintManager( pRTC );
The archive can be based on the memory file and you can exchange the content of the memory file with the registry. The CExtCmdManager::FileObjFromRegistry() method loads the registry location into the memory file. The CExtCmdManager::FileObjToRegistry() method saves the memory file to the specified registry location.

Alexander Kool Aug 15, 2006 - 6:31 AM

Thanks,
I tried it, but get a Exeption in CArchive::WriteClass(pRTC) on line

if (pClassRef->m_wSchema == 0xFFFF)
{ ... AfxThrowNotSupportedException(); ... }

It seems that the Schema is -1.
I noted that the Paintmanager classes are not implemented as IMPLEMENT_SERIAL see:
IMPLEMENT_DYNCREATE( CExtPaintManager, CObject )
IMPLEMENT_DYNCREATE( CExtPaintManagerXP, CExtPaintManager )
IMPLEMENT_DYNCREATE( CExtPaintManagerOffice2003, CExtPaintManagerXP )
IMPLEMENT_DYNCREATE( CExtPaintManagerOffice2003NoThemes, CExtPaintManagerOffice2003 )
IMPLEMENT_DYNCREATE( CExtPaintManagerStudio2005, CExtPaintManagerOffice2003 )
IMPLEMENT_DYNCREATE( CExtPaintManagerNativeXP, CExtPaintManager )
IMPLEMENT_DYNAMIC( CExtPaintManagerOffice2007_Impl, CExtPaintManagerOffice2003 )
IMPLEMENT_DYNCREATE( CExtPaintManagerOffice2007_R1, CExtPaintManagerOffice2007_Impl )
IMPLEMENT_DYNCREATE( CExtPaintManagerOffice2007_R2_LunaBlue, CExtPaintManagerOffice2007_Impl )
IMPLEMENT_DYNCREATE( CExtPaintManagerOffice2007_R2_Obsidian, CExtPaintManagerOffice2007_Impl )

Should’t that be the case ??

Even when I change the Schema to non-zero (break-point and manual change), the WriteClass continues, but my MemFile is still empty.
Any suggestions ?

My full code is:
void CJecadApp::LoadRegTheme() // Called from InitInstance
{	// Load the previous Theme
	CMemFile MFile;
	CExtCmdManager::FileObjFromRegistry(MFile, _T("Theme"));

	if (MFile.GetLength() != 0)
	{	// We seem to have a stored Theme setting
		CArchive ar(&MFile, CArchive::load);
		CExtPaintManager * pPM = g_PaintManager.GetPM();
		CRuntimeClass * pRTC = pPM->GetRuntimeClass();
		pRTC = ar.ReadClass(pRTC);
		g_PaintManager.InstallPaintManager(pRTC);
	}
}


void CJecadApp::StoreRegTheme() // Called from ExitInstance
{
	CExtPaintManager * pPM = g_PaintManager.GetPM();
	CRuntimeClass * pRTC = pPM->GetRuntimeClass();
	CMemFile MFile;
	CArchive ar(&MFile, CArchive::store);
	ar.WriteClass(pRTC);

	CExtCmdManager::FileObjToRegistry(MFile, _T("Theme"));
}

Technical Support Aug 15, 2006 - 7:04 AM

We are sorry, that was our fault. We decided to switch to serializable run-time info for paint manager classes. You can change this manually to DECLARE_SERIAL/IMPLEMENT_SERIAL or contact us via e-mail so we can provide the updated source code.

Eric Houvenaghel Sep 12, 2006 - 1:22 PM

Hello,
I am trying to use the above code as well.
I’ve change the DECALRE_SERIAL and IMPLEMENT_SERIAL in CExtPainManager.
Recompiled everything including my own project.
I’m getting an empty memory file as well.
The FileObjToRegistry is writing the data_integrity and data_size reg keys to 0.
Any suggestions is appreciated.
Thanks.

Eric Houvenaghel Sep 12, 2006 - 1:29 PM

I found the bug.
ar.Fulsh() must be called after ar.WriteClass(pRTC) and before CExtCmdManager::FileObjToRegistry(MFile, _T("Theme"))
I knew it was trivial.

Brett Cook Oct 30, 2006 - 4:02 PM

Does the above code still work in 2.60? The store seems to work, but I get an exception on the load (while trying to call ReadClass from the archive).

Brett Cook Oct 30, 2006 - 4:13 PM

This does work. The problem was I was installing the paintmanager twice.