Print Page | Close Window

Serializing Controls and dynamic updates

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=11213
Printed Date: 10 June 2024 at 12:02am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Serializing Controls and dynamic updates
Posted By: MacW
Subject: Serializing Controls and dynamic updates
Date Posted: 26 June 2008 at 6:04am
Hi,

I use CXTPPropExchangeSection and DoPropExchange to load/store docking panels, menu bars, toolbars etc. in a database.

Our application (especially while developing) gets new menu items and commands frequently. On runtime we also add/remove menu items depending on the availability of plug-ins or the current user. We also change the name of menu entries based on the current language, or the application mode.

The problem is that new menu entries don't show up in the menus when we load them from the archive. It seems that CJ is not only storing the layout of the menues, but also the names of the menus.

How can I restore the position and layout of menus and other control bars, but have the flexibility to change the name of a menu between application settings. XTP should not store the menu name string in the layout, right?





Replies:
Posted By: Oleg
Date Posted: 26 June 2008 at 12:03pm
Hi,
 
Its all depend what you do in your code.


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


Posted By: MacW
Date Posted: 26 June 2008 at 7:17pm
I do what you do in your samples, or what one may be able to grasp from your documentation.

But when I change the menu bar (add entries, change the name of entries), and then call the methods to load the stored state, the new entries in the menu are no longer there and the old names are displayed.

From what I can tell, your serialization methods store the complete menu, including the names of the menu entries. Instead of just the position of the menu. Is this correct?


Posted By: Oleg
Date Posted: 27 June 2008 at 1:28am
Hi,
 
Yes it stores all entries.


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


Posted By: MacW
Date Posted: 27 June 2008 at 8:20am
Is there a "How-To"how to deal with this?

Applications are dynamic, and updates may bring new menu commands, changed entries, order of menu entries etc.

As far as I can see it, with the current XTP version I can only tell my users to throw away all their saved workspaces (containing docking pane layouts, toolbar positions, custmizations) when I bring out a new version.
They won't like this because it takes quite some time to setup your custom workspace...




Posted By: Oleg
Date Posted: 27 June 2008 at 4:40pm

Hi,

Please attach new sample to show what you do and what problem you have.
 
It have to work by default. You do something wrong in your code.


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


Posted By: MacW
Date Posted: 12 July 2008 at 4:20am
Hi, Oleg

I'm doing nothing special. I load a menu from my "resource manager" into a CMenu, and then


CXTPMenuBar* pxtpmenu =
pCommandBars->SetMenu(_T("Menu") IDR_MAINFRAME);

// Load the menu from the res mgr. The menu may have
// changed since the last time the application ran, or the user
// now works in a different language...

CMenu mnu;
MyResManager.GetMenu(123,mnu);

pxtpmenu->LoadMenu(mnu);

// The steps above ensure that the menu is there
// Now my code looks if there is a saved XTP state, and if so, loads it

...
CXTPPropExchangeArchive px(ar);
           CXTPPropExchangeSection pxCommandBars(px.GetSection(_T("CommandBars")));
            XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
            param.bSerializeControls = TRUE;
            GetCommandBars()->DoPropExchange(&pxCommandBars, &param);

            CXTPPropExchangeSection pxpanes(px.GetSection(_T("DockingPane")));
            CXTPDockingPaneLayout layoutNormal(&m_paneManager);
            if (layoutNormal.DoPropExchange(&pxpanes)) {
                m_paneManager.SetLayout(&layoutNormal);
            }


The problem is that when the menu I load with LoadMenu has changed since the last run (new items added or removed), or the names of the items have changed in the menu (language switch), the

m_paneManager.SetLayout(&layoutNormal);

will invalidate all these changes. This call restores for example the names of the menu items as they were on the last save, not recognizing that they have changed. The layout apparently does not contain only the position of the menu but also the plain text names, descriptions, tool tip texts etc.

So far the only thing that helps is to skip the call to load the layout when I did make changes to the menu or the names used in the menu. But then all docking panel positions etc. will also be reset to default values. My users won't like this.

Is there a way in XTP to store only the positions, docking states etc. but not the actual items and commands used in the toolbars and menus?







Posted By: Smucker
Date Posted: 13 July 2008 at 9:08am
I agree that this is a major problem, creating a support nightmare: users either lose their customizations or are missing new and changed commands. Both cause complaints and support calls.



-------------
Product: Xtreme Toolkit Pro version 13.2 (Unicode, static build)

Platform: Windows 200x/XP/Vista/Win7 (32/64 bit)

Language: Visual C++ 9.0 (Studio 2008)



Posted By: MacW
Date Posted: 16 July 2008 at 4:44am
Yeah, I think this too.

But I'd would appreciate an official comment from Oleg or another Codejock Supporter.

I don't think that Codejock has intented this to work this way because it would not fit the otherwise very good quality of the product.

All I want to have is a safe way to restore the positions and size of docking panels and toolbars, even when some of the menu items have changed in-between. This cannot be so difficult, but frankly, all the serialization stuff in XTP has become so complex, I don't know where to begin...


Posted By: Oleg
Date Posted: 16 July 2008 at 5:48am
Hi,
 
It works by default. You can check our samples.


-------------
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