How to use at the time of adding IniFile |
Post Reply |
Author | |
ledled
Newbie Joined: 18 November 2007 Status: Offline Points: 9 |
Post Options
Thanks(0)
Posted: 26 November 2007 at 1:28am |
Hi Oleg
Oh,It found out the meaning which you said.
Works great, thanks oleg!
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Just don't call LoadFromFile if you use AssignFile
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
ledled
Newbie Joined: 18 November 2007 Status: Offline Points: 9 |
Post Options
Thanks(0)
|
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, ¶m); px.SaveToFile(_T("D:\\ledled.ini")); |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
ledled
Newbie Joined: 18 November 2007 Status: Offline Points: 9 |
Post Options
Thanks(0)
|
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?
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
SaveToFile replaces previous file.
You can add px.LoadFromFile() in the second line to load previous state.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
ledled
Newbie Joined: 18 November 2007 Status: Offline Points: 9 |
Post Options
Thanks(0)
|
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, ¶m); 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, ¶m); px.SaveToFile(_T("D:\\ledled.ini")); |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |