Print Page | Close Window

How to use at the time of adding IniFile

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=8829
Printed Date: 02 March 2025 at 3:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to use at the time of adding IniFile
Posted By: ledled
Subject: How to use at the time of adding IniFile
Date Posted: 18 November 2007 at 9:45pm
Hello,
 
It is overwritten when it is written this code from more than one dialog.
Can't you mention it in the same file in another section?
 
//Dialog A
 CXTPPropExchangeIniFile px(FALSE, _T("Main"), _T("Settings"));
    CXTPCommandBars* pCommandBars = GetCommandBars();
    XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
    param.bSaveOriginalControls = TRUE;
    param.bSerializeControls = TRUE;
 param.bSerializeImages = TRUE;
 param.bSerializeDesignerControls = TRUE;
    param.bSerializeOptions = TRUE;
 param.bSerializeLayout = TRUE;
 pCommandBars->DoPropExchange(&px, &param);
 px.SaveToFile(_T("D:\\ledled.ini"));
 
//Dialog B
 CXTPPropExchangeIniFile px(FALSE, _T("Sub"), _T("Settings"));
    CXTPCommandBars* pCommandBars = GetCommandBars();
    XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
    param.bSaveOriginalControls = TRUE;
    param.bSerializeControls = TRUE;
 param.bSerializeImages = TRUE;
 param.bSerializeDesignerControls = TRUE;
    param.bSerializeOptions = TRUE;
 param.bSerializeLayout = TRUE;
 pCommandBars->DoPropExchange(&px, &param);
 px.SaveToFile(_T("D:\\ledled.ini"));
 



Replies:
Posted By: Oleg
Date Posted: 19 November 2007 at 1:28am
Hi,
SaveToFile replaces previous file.
 
You can add px.LoadFromFile() in the second line to load previous state.


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


Posted By: ledled
Date Posted: 19 November 2007 at 3:02am
Hi Oleg
Thanks for replying.
 
It was already tried.
But if the first argument of a constructor is not TRUE, px.LoadFromFile asserts.
Is there a method which m_bLoading is changed to after CXTPPropExchangeIniFile is defined?


Posted By: Oleg
Date Posted: 19 November 2007 at 8:46am
Hi,
 
Oh I didn't noticed you have CXTPPropExchangeIniFile  instead of CXTPPropExchangeXMLNode.
 
For ini you can call
 
px.AssignFile(_T("D:\\ledled.ini"));


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


Posted By: ledled
Date Posted: 21 November 2007 at 12:39am
Hi Oleg
Thanks for your help.
 
AssignFile can't avoid Assert of LoadToFile.
Because it only call this.
 
----------------------------------------
void CXTPPropExchangeIniFile::AssignFile(LPCTSTR strFileName)
{
 m_strFileName = strFileName;
 m_bTempFile = FALSE;
 m_bEmptySection = FALSE;
}
BOOL CXTPPropExchangeIniFile::LoadFromFile(LPCTSTR strFileName)
{
 ASSERT(IsRootSection() && IsLoading()); // It asserts here.
 if (!FILEEXISTS_S(strFileName))
  return FALSE;
 if (!OnBeforeExchange())
  return FALSE;
 return ::CopyFile(strFileName, m_strFileName, FALSE);
}
----------------------------------------
 
First of all it is doing like this now.
 
class CXTPPropExchangeIniFileEx : public CXTPPropExchangeIniFile
{
public:
 CXTPPropExchangeIniFileEx(BOOL bLoading, LPCTSTR lpszParentSection,LPCTSTR lpszSection)
  : CXTPPropExchangeIniFile(bLoading, lpszParentSection, lpszSection) {};
 virtual ~CXTPPropExchangeIniFileEx(){};
 int SetLoadFlg(BOOL bLoad){this->m_bLoading = bLoad; return 0;};
};
 
 
//Dialog A
 CXTPPropExchangeIniFileEx px(TRUE, _T("Main"), _T("Settings"));
 px.LoadFromFile(_T("D:\\ledled.ini"));
 px.SetLoadFlg(FALSE);       // m_bLoad is changed here.
 CXTPCommandBars* pCommandBars = GetCommandBars();
 XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
 param.bSaveOriginalControls = TRUE;
 param.bSerializeControls = TRUE;
 param.bSerializeImages = TRUE;
 param.bSerializeDesignerControls = TRUE;
 param.bSerializeOptions = TRUE;
 param.bSerializeLayout = TRUE;
 pCommandBars->DoPropExchange(&px, &param);
 px.SaveToFile(_T("D:\\ledled.ini"));
 
 
 
 
 
 


Posted By: Oleg
Date Posted: 21 November 2007 at 9:04am
Hi,
Just don't call LoadFromFile if you use AssignFile


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


Posted By: ledled
Date Posted: 26 November 2007 at 1:28am
Hi Oleg
 
Oh,It found out the meaning which you said.
Works great, thanks oleg!



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