Print Page | Close Window

Module state problems loading saved commandbars

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=6668
Printed Date: 03 March 2025 at 7:43pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Module state problems loading saved commandbars
Posted By: ZakR
Subject: Module state problems loading saved commandbars
Date Posted: 18 March 2007 at 7:51am
I have a C++/MFC dll which uses Codejock toolbars.  This dll is loaded dynamically from a C#.NET application through ::LoadLIbrary(). The toolbars have been saved with SaveCommandBars() but LoadCommandBars() fail to restore them. I've traced the problem to the following:
 
When my dll is loaded, Windows automatically also loads the CodeJock dll. Since the Codejock classes uses the DECLARE_SERIAL macro, the various CommandBar class names are registered in MFC's ModuleState->m_classList.  This happens during load of the dll, and the module state at that time is the main application.
 
However, after the dll's are loaded, my dll starts up and tries to restore the commandbars with LoadCommandBars().  LoadCommandBars() will try to load the serialized commandbars, but the serialize code fails to find any CodeJock class names in the ModuleState->m_classList, because at this point, the module state is my dll, and not the main app.  So CRuntimeClass::FromName() will fail, and the MFC serialize code throws an exception.
 
Now what am I doing wrong here? How can I ensure that LoadCommandBars() operate in the same module state as when the CodeJock library was loaded by Windows?
 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net