Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPPropExchange faq
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPropExchange faq

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


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPropExchange faq
    Posted: 27 February 2008 at 7:03am
Hello,

i use CXTPPropExchange function to save & store some data.

static void PropLOS2Data(CXTPPropExchange* pPX, SLOS2Data& ld)
{
    CXTPPropExchangeSection secLD(pPX->GetSection("LOS2Data"));

    PX_ULong(&secLD, _T("CRC"), ld.dwCRC, 0);
    PX_ULong(&secLD, _T("LenData"), ld.dwLenData, 0);
    // ??? PX_CharBuffer(&secLD, _T("PasswordOnline"), ld.szPasswordOnline, "");
}

With this function i save/load some data from a struct.
DWORD, int values are no problem.

#define MAX_PASSWORD   19

struct SLOS2Data
{
  ULONG dwCRC;
  ULONG dwLenData;
  char szPassword[MAX_PASSWORD + 1];
}

But how can i save/load szPassword ?
The szPassword is always \0 terminated.

I have wrote this template, but how can i save/load it ?
Or is there a other nice solution ?

template<class TYPE> BOOL PX_CharBuffer(CXTPPropExchange* pPX, LPCTSTR pszPropName, TYPE& szBuf, LPCTSTR lpDefault)
{
    int iBufSize = sizeof(szBuf);
    // DWORD nBytes = iBufSize;
    // return PX_Blob(pPX, pszPropName, szBuf, nBytes);
}

  Jimmy

Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2008 at 7:31am
Is this a correct way ?

template<class TYPE> void CharBufCpy(TYPE& szBuf, const CString& lpText)
{
    int iSize = sizeof(szBuf) - 1;
    memset(szBuf, 0, iSize + 1);
    int iLenText = lpText.GetLength();
    if (iLenText > iSize)
        iLenText = iSize;
    strncpy(szBuf, lpText, iLenText);
}

template<class TYPE> BOOL PX_CharBuffer(CXTPPropExchange* pPX, LPCTSTR pszPropName, TYPE& szBuf, LPCTSTR lpDefault)
{
    if (pPX->IsStoring())
    {
        CString strVal(szBuf);
        return PX_String(pPX, pszPropName, strVal);
    }
    else
    {
        CString strVal;
        BOOL bOk = PX_String(pPX, pszPropName, strVal, lpDefault);
        if (bOk)
            CharBufCpy(szBuf, strVal);
        return bOk;
    }
}

  Jimmy

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: 27 February 2008 at 1:40pm
Hi,
 
Maybe easy to change "char szPassword" to "CString strPassword" in struct ?
:)
 
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 516
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2008 at 3:09am
No, because the struct is a binary mapping of a file.

  Jimmy

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