Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - LoadCommandBar error
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

LoadCommandBar error

 Post Reply Post Reply
Author
Message
maxxan View Drop Down
Groupie
Groupie


Joined: 15 July 2009
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote maxxan Quote  Post ReplyReply Direct Link To This Post Topic: LoadCommandBar error
    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?
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
maxxan View Drop Down
Groupie
Groupie


Joined: 15 July 2009
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote maxxan Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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).
Back to Top
maxxan View Drop Down
Groupie
Groupie


Joined: 15 July 2009
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote maxxan Quote  Post ReplyReply Direct Link To This Post 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! :)
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.