Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - How to use at the time of adding IniFile
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to use at the time of adding IniFile

 Post Reply Post Reply
Author
Message Reverse Sort Order
ledled View Drop Down
Newbie
Newbie


Joined: 18 November 2007
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote ledled Quote  Post ReplyReply Direct Link To This Post Topic: How to use at the time of adding IniFile
    Posted: 26 November 2007 at 1:28am
Hi Oleg
 
Oh,It found out the meaning which you said.
Works great, thanks oleg!
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 21 November 2007 at 9:04am
Hi,
Just don't call LoadFromFile if you use AssignFile
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
ledled View Drop Down
Newbie
Newbie


Joined: 18 November 2007
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote ledled Quote  Post ReplyReply Direct Link To This Post 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"));
 
 
 
 
 
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
ledled View Drop Down
Newbie
Newbie


Joined: 18 November 2007
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote ledled Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
ledled View Drop Down
Newbie
Newbie


Joined: 18 November 2007
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote ledled Quote  Post ReplyReply Direct Link To This Post 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"));
 
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.109 seconds.