Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Using XML bars customization
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using XML bars customization

 Post Reply Post Reply
Author
Message
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post Topic: Using XML bars customization
    Posted: 15 February 2006 at 3:44am

Hi,

In my application I use XML bars customization. I have about 4 DocTemplates and I want to store a different bars layout for each one of them. I prefer to work with one xml file (and make 4 different sections for each DocTemplate). My problem is that it looks like each time I use the method SaveToFile (of CXTPPropExchangeXMLNode), the file is written from scratch, and the previous sections are deleted.

My question is: Can I do it with one XML file with 4 sections, or should I compromise on 4 different XML files for each layout ?

Here is my code (which is called each time a different DocTemplate is load):

CCimString aCustomizationFileName = GetCustomizationFileName();
CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));
if (px.OnBeforeExchange())
{
 CXTPPropExchangeSection pxCommandBars(px.GetSection(aStateName));
 XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
 param.bSerializeControls = TRUE;
 param.bSaveOriginalControls = FALSE;
 mToolBarManager->DoPropExchange(&pxCommandBars, &param);
 px.SaveToFile(aCustomizationFileName);
}

Yoav.

 

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 15 February 2006 at 7:53am

Just add

px.LoadFromFile(aCustomizationFileName);

after CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2006 at 6:47am

Hi Oleg,

I tried to follow your instructions but I have some problems with this solusion (I tried to do it also in "Gui_Whidbey" sample and had the same problems as in my App ):

1. The size of the .xml file keeps growing each time I save the layout to the file.

2. The customization does not work OK (if I rename a menu item and run the application again, the renamed name is not restored). I think it happens because the section is not written from scrach and it contains "leftovers" of previous layout saving.

Yoav.

Back to Top
yoavo View Drop Down
Senior Member
Senior Member


Joined: 29 February 2004
Location: Israel
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavo Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2006 at 2:36am

I also tried it in "Grep" sample (without changing the code) - in this sample you use the same solusion, and the problem exist there too: Try to rename a menu item by customization - it will not be kept, and the .xml file is growing each time you close the application.

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 02 March 2006 at 3:47pm

To solve problem 1:

replace

param.bSaveOriginalControls = FALSE;

to

param.bSaveOriginalControls = TRUE;

 

To solve problem 2:

call

pxCommandBars->EmptySection();

before GetCommandBars()->DoPropExchange(&pxCommandBars, &param);

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.078 seconds.