LoadCommandBar error |
Post Reply |
Author | |
maxxan
Groupie Joined: 15 July 2009 Status: Offline Points: 49 |
Post Options
Thanks(0)
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?
|
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
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.
|
|
maxxan
Groupie Joined: 15 July 2009 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
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..
|
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
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).
|
|
maxxan
Groupie Joined: 15 July 2009 Status: Offline Points: 49 |
Post Options
Thanks(0)
|
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! :)
|
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
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.
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |