Save to XML ?
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=14327
Printed Date: 27 February 2025 at 5:59pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Save to XML ?
Posted By: kanitamildasan
Subject: Save to XML ?
Date Posted: 19 May 2009 at 1:06am
Hi,
How to save the .RC file to XML file that we can load using CommandBars LoadDesignerBars() ?
Thanks
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Replies:
Posted By: kanitamildasan
Date Posted: 19 May 2009 at 2:51am
Hi,
I have tried to use the menu grabber from the Commandbars Designer to capture the menu of our application(app uses the XT Menubar) the grabber didnt grabbed the menu ? (but the grabber works with notepad perfectly)
Thanks
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 20 May 2009 at 2:08am
Yes, grabber can grab only standard menus.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 20 May 2009 at 4:03am
Thanks Oleg, Is there anyother way to save .RC to XML which can be loaded using LoadDesignerBars()?
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 21 May 2009 at 1:57am
Hi,
You can create menu first from .RC and then GetCommandBars()->DoPropExchange to save to XML.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 21 May 2009 at 4:45am
Thanks Oleg,
1) The XML file have different tags when we save using CommandBars Designer and DoPropExchange.
2) I have saved an XML using DoPropExchange and tried to open in CmdDesigner but i got errors about the missing tags.I fixed it by changing "Settings" to "DesignerFile" than the error didnt come but cmdbars designer remains empty.
3) And i tried to load the DoPropExchange's XML using LoadDesignerBars() in the Designer Sample but i didnt get any menu or toolbar in the application.
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: kanitamildasan
Date Posted: 21 May 2009 at 7:53am
Hi, How to write XML file using DoPropExchange which can read by CommandBars Designer or LoadDesignerBars() ?
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 21 May 2009 at 8:37am
Hi,
please open new ticket in issuetrack - show all code you call to save CommandBars.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 22 May 2009 at 12:39am
Hi Oleg, I have used the Support form to post the question.
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: kanitamildasan
Date Posted: 28 May 2009 at 12:51am
Oleg, I have posted the question (which is the same question I posted here in the forum on 19-May-2009) in the IssueTrack but unfortunately our subscribtion for XT Pro expired on 26-May-2009 so the Customer Service cant able assign the issue for assistance.
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 28 May 2009 at 5:10am
Set all params to true when you save it
XTP_COMMANDBARS_PROPEXCHANGE_PARAM param; param.bSerializeControls = TRUE; param.bSerializeDesignerControls = TRUE; param.bSerializeImages = TRUE; param.bSerializeOptions = TRUE; param.bSerializeActions = TRUE;
GetCommandBars()->DoPropExchange(&px, ¶m);
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 28 May 2009 at 9:08am
uploads/20090528_090733_Resources.zip - uploads/20090528_090733_Resources.zip
Hearty Thanks for considering my request.
I have created a default sample using the VC++ 6 wizard provided by CodeJock. And pasted the code you provided in
void CMainFrame::OnClose()
{
// Save the current state for toolbars and menus.
SaveCommandBars(_T("CommandBars"));
CString m_strXmlFileName = "Resources.xml";
CXTPPropExchangeXMLNode pPX(FALSE, 0, _T("DesignerFile")); // To serialize to XML file
XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
param.bSerializeControls = TRUE;
param.bSerializeDesignerControls = TRUE;
param.bSerializeImages = TRUE;
param.bSerializeOptions = TRUE;
param.bSerializeActions = TRUE;
GetCommandBars()->DoPropExchange(&pPX, ¶m);
pPX.SaveToFile(m_strXmlFileName);
CMDIFrameWnd::OnClose();
}
I have the AfxOleInit() in InitInstance. But the XML file saved by this sample app didnt have CommandBars node in the XML file. (I have attached the file.)
Thanks
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: kanitamildasan
Date Posted: 29 May 2009 at 1:18am
uploads/20090529_011719_XTEmpty2.zip - uploads/20090529_011719_XTEmpty2.zip
Hi Oleg, I have attached the full sample application code.
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 29 May 2009 at 1:49am
Hi,
right, you also need
param.bSaveOnlyCustomized = FALSE;
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 29 May 2009 at 3:22am
Thanks Oleg,
Now i can able to load the CommandBars from the XML using LoadDesignerBars() but the handler for ON_XTP_CREATECONTROL() didnt called by XT ?
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: kanitamildasan
Date Posted: 30 May 2009 at 7:49am
Hi, How to create CustomControls without using OnCreateControl() ?
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 01 June 2009 at 8:08am
Hi,
create with new CXTPControlCustom() and insert with pToolbar->GetControls()->Add(pControl);
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 01 June 2009 at 8:23am
Thanks Oleg,
Do i need to add pToolbar->GetControls()->Add(pControl); in Mainframe::OnCreate() ? LoadFrame() ? Add() will add the control at the end of toolbar controls but OnCreateControl() really provides an easy way to Put Customcontrols in the Toolbar in their own location.
My old code that uses the loading of commandbars from resource works when i create custom controls in OnCreateControl() but when i Load Commandbars using the LoadDesignerBars() using XML file it didnt work the same way so i dont know which event will be called by LoadDesignerBars() where i can create custom controls which provides similar function of OnCreateControl() rather than using Add() method ...
2) oncreatecontrol() ? 2) createcommandbar() ? 3) oninitcommandspopup() ? 4) other ?
Thanks again
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 02 June 2009 at 2:27am
Hi,
Just call it after you already load designer bars.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 02 June 2009 at 2:52am
Thanks Oleg, I will check out ...
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: kanitamildasan
Date Posted: 04 June 2009 at 1:20am
Hi Oleg,
I have added a CommandButtonPopup(ColorPopup) using the pToolbar->GetControls()->Add() method after LoadDesignerBars(), the new button appears on the toolbar but still the OnCreateControl() is not called ?
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 04 June 2009 at 2:10am
Hi,
Yes, OnCreateControl is called only when you add buttons using IDs (pToolBar->SetButtons or pToolBar->LoadToolBar). If you manually create it, its not called.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 04 June 2009 at 5:16am
Thanks Oleg,
I am creating a ColorPopup in the OnCreateControl() like
if (lpCreateControl->nID == ID_COLOR) { CXTPControlPopupColor* pPopupColor = new CXTPControlPopupColor();
CXTPPopupBar* pColorBar = CXTPPopupToolBar::CreatePopupToolBar(GetCommandBars()); pPopupColor->SetCommandBar(pColorBar);
pColorBar->GetControls()->Add(new CXTPControlButtonColor(), XTP_IDS_AUTOMATIC_FILL); pColorBar->GetControls()->Add(new CXTPControlColorSelector(), ID_SELECTOR_FILL); pColorBar->GetControls()->Add(new CXTPControlButtonColor(), XTP_IDS_MORE_COLORS_FILL);
pColorBar->SetTearOffPopup(_T("Color"), 1006, 0);
pColorBar->InternalRelease();
lpCreateControl->pControl = pPopupColor;
return TRUE; }
and a custom control like
if (lpCreateControl->nID == ID_STYLE) { CXTPControlCustom* pControl = CXTPControlCustom::CreateControlCustom(&m_wndComboStyle); pControl->SetFlags(xtpFlagManualUpdate) ; lpCreateControl->pControl = pControl;
return TRUE; }
If we use XML which is the best way to do the same ?
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
Posted By: Oleg
Date Posted: 04 June 2009 at 8:13am
Hi,
So just use same code - first create control and then add it with pToolBar->GetControls()->Add(pPopupColor );
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: kanitamildasan
Date Posted: 04 June 2009 at 8:27am
Hearty Thanks Oleg for your support and spending your valuable time for me. 
------------- Xtreme ToolkitPro 12.1.1
Win XP (32bit) - SP2
Visual C++ 6.0 SP 6
|
|