Print Page | Close Window

LoadCommandBar error

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=17697
Printed Date: 04 October 2024 at 9:23pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: LoadCommandBar error
Posted By: maxxan
Subject: LoadCommandBar error
Date Posted: 17 December 2010 at 6:59am
I'm trying to save/load command bars, but it doesn't seem to load (or save?) correctly.

I've created a ribbon in code (not using CommandBarDesigner) and after that (in OnCreate) I call LoadCommandBars, which fails to load previously saved command bars.

It is in CXTPCommandBars::LoadCommandBarList that I get an CArchiveException after it has successfully loaded some of the command bars.

What might the problem be? Any ideas?



Replies:
Posted By: rdhd
Date Posted: 23 January 2011 at 11:45am
I believe I have had this same error when I had a custom control on the command bar which was not exported from a MFC extension DLL. I was able to step thru all the CodeJock load code until my class name was encountered. When CJ tried to create the class I stepped thru the MFC code. That code loops thru all the extension DLLs trying to find a class constructor for my subclassed class name. That failed and CJ threw the exception.
 
I found our custom class code and moved it from a non-MFC exension DLL to a DLL that was an MFC extension DLL. That fixed my issue.
 
If you have your own subclassed controls, this might be your problem too.


Posted By: maxxan
Date Posted: 28 February 2011 at 4:30am
I don't use any DLL's at all. All my controls I create in the main code. But maybe it's some similar problem. The problem is in CArchive::ReadClass, this part:

DWORD obTag;
WORD wTag;
*this >> wTag;
if (wTag == wBigObjectTag)
*this >> obTag;
else
obTag = ((wTag & wClassTag) << 16) | (wTag & ~wClassTag);

// check for object tag (throw exception if expecting class tag)
if (!(obTag & dwBigClassTag))
{
if (pObTag == NULL)
AfxThrowArchiveException(CArchiveException::badIndex, m_strFileName);

*pObTag = obTag;
return NULL;
}

Here obTag  is NULL and I get an exception. I can't seem to find out why..


Posted By: rdhd
Date Posted: 10 March 2011 at 1:21pm
When you save out the command bars, you have to have runtime class info available. If you ask CJ to save to a file, you can open the file (it is xml data) and you can add your control to the qat and save and then examine what CJ wrote. You want to see your class name in the CJ file. Your class needs to support dynamic creation (using the declare_dynamic and implement_dynamic MFC macros). Sounds like your class is not dynamic (assuming that point since your class tag is NULL).
 
And your .exe is a DLL. If it is a standard MFC exe, I think it will be in the DLL list. When you step thru the loading code, at some point I expect CJ to try and create the class object (using the runtime class info and name) and you should be able to see your exe as one of the modules in the list. You may only see module handles in the MFC code and I am thinking the first module will be your exe. When running debug, you can turn on the modules window and then find the row with your exe/dll on it (the exe should be the first line if you have not ordered based on one of the columns). The data in the window includes the range of the module (under the "address" column). I believe the start of the range is also your module handle value. So you can note that value in the debug module window and as MFC walks the extension DLL chain, you can tell when your module is encountered.
 
Each module has a MFC class (name) map. Once you have your module data, you can examine the class map in the debug watch window and see what classes are present (if any). Or you can keep stepping thru the MFC code and it will get each class name in the list and compare to the class name CJ has read from their file (or registry if you don't give a filename to save to).


Posted By: maxxan
Date Posted: 14 March 2011 at 7:17am
I tried with implement/declare dynamic (I used DECLARE_XTP_CONTROL and IMPLEMENT_XTP_CONTROL before) but same error.

I event tried to skip to create all tabs, just having the system button and quick access bar and no custom buttons, but still same error.

It works fine if I save/load to/from ini-file but registry and CArchive doen't work.. Hard nut to crack! :)


Posted By: rdhd
Date Posted: 14 March 2011 at 10:23am
I have been able to save to the registry or their xml file. I even save the command bars to a node in my own xml file by supplying the "node" element in the CXTPropExchangeSection object's constructor.
 
I still suspect an MFC issue since I have all three of the above working.


Posted By: Oleg
Date Posted: 14 March 2011 at 2:49pm
maxxan, try to reduce your applicaiton or move important cod to new apwizard project, reproduce problem and attach here/support to review what you do.
Now its very odd how to help here.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



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