Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - [SOLVED]Thousand character in the Subtotal of Gro
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED]Thousand character in the Subtotal of Gro

 Post Reply Post Reply
Author
Message
ylaroye View Drop Down
Groupie
Groupie


Joined: 01 November 2018
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote ylaroye Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED]Thousand character in the Subtotal of Gro
    Posted: 11 May 2019 at 4:41pm
I am disappointed to see that my following proposal for evolution was not retained in version 19.0.0 Beta 1 while it is legitimate and that I proposed the code to implement it. Why?

------------------------------------
In a financial application, there is need to present the amounts with the thousand separator. This can be done for the elements in the ReportControl lines but not for the GroupRow.
I propose an evolution on the SetFormatString method allowing to manage:
- the thousand separator => keyword 'T'
- the decimal separator => keyword 'D'
- the sign '-' (sometimes represented with parentheses: -1234 => (1234)) => keyword 'N'

These 3 elements must be put between '[]' after the '%' and the value of each element is the character just behind the keyword.
Example: 'Subtotal =% [T D, N (]. 02f $'
    T = Blank
    D = Comma
    N = Parenthesis




Product: XTP 18.6.0 and XTP 19.0.0 Beta 1 on VC++ 6.0
Platform: Windows 10 (64bit)

Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 120
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 03 June 2019 at 6:11am
Hello,

We added same functionality but by using CURRENCYFMT structure and GetCurrencyFormat function. This allows to get currency string  more flexible.

See BOOL CFormulaDlg::OnInitDialog() function in ReportSample.



Regards,
Artem Gontarenko
Back to Top
ylaroye View Drop Down
Groupie
Groupie


Joined: 01 November 2018
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote ylaroye Quote  Post ReplyReply Direct Link To This Post Posted: 03 June 2019 at 7:56am
Hello Artem,

CURRENCYFMT structure and GetCurrencyFormat function are only used in Source\Chart\Utils\XTPChartNumberFormat.cpp and XTPChartNumberFormat.h files.

I haven't seen in Xtreme ToolkitPro v19.0.0.050119 where CURRENCYFMT structure and GetCurrencyFormat function are used for the ReportControl (in "Source" and "Samples" sub-folders).

Can you send me your modified FormulaDlg.cpp/FormulaDlg.h files to understand how you have implemented it?

Regards,

Yves Laroye



Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 120
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 03 June 2019 at 9:18am
This changes from FormulaDlg

// FormulaDlg.h

    ~CFormulaDlg();
    CURRENCYFMT m_fmtCurrency;
    int GetLocaleLong(LCTYPE LCType);
   
   
// FormulaDlg.cpp
   
CFormulaDlg::CFormulaDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CFormulaDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CFormulaDlg)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
   
    ZeroMemory(&m_fmtCurrency, sizeof(m_fmtCurrency));
    m_fmtCurrency.lpDecimalSep     = new TCHAR[10];
    m_fmtCurrency.lpThousandSep    = new TCHAR[10];
    m_fmtCurrency.lpCurrencySymbol = new TCHAR[10];
    m_fmtCurrency.Grouping        = 3;
    m_fmtCurrency.NumDigits        = GetLocaleLong(LOCALE_IDIGITS);
    m_fmtCurrency.LeadingZero   = GetLocaleLong(LOCALE_ILZERO);
    m_fmtCurrency.NegativeOrder = GetLocaleLong(LOCALE_INEGCURR);
    m_fmtCurrency.PositiveOrder = GetLocaleLong(LOCALE_ICURRENCY);
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, m_fmtCurrency.lpDecimalSep, 10);
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, m_fmtCurrency.lpCurrencySymbol, 10);
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, m_fmtCurrency.lpThousandSep, 10);
}

CFormulaDlg::~CFormulaDlg()
{
    SAFE_DELETE_AR(m_fmtCurrency.lpDecimalSep);
    SAFE_DELETE_AR(m_fmtCurrency.lpThousandSep);
    SAFE_DELETE_AR(m_fmtCurrency.lpCurrencySymbol);
}

int CFormulaDlg::GetLocaleLong(LCTYPE LCType)
{
    TCHAR szResult[5];

    int nResult = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LCType, szResult, 4);
    ASSERT(nResult == 2);
    UNUSED(nResult);
    return _ttoi(szResult);
}

BOOL CFormulaDlg::OnInitDialog()
{
    ...

        { _T("Pen"), _T("WA"), -200000 },    { _T("Paper"), _T("WA"), 100000 },
        { _T("Books"), _T("WA"), 100000 },
    };

    ...

    BOOL bUseCurrencyFormat = TRUE;
    for (i = 0; i < m_wndReport.GetRows()->GetCount(); i++)
    {
        CXTPReportRow* pRow = m_wndReport.GetRows()->GetAt(i);

        if (pRow->IsGroupRow())
        {
            CXTPReportGroupRow* pGroupRow = reinterpret_cast<CXTPReportGroupRow*>(pRow);
           
            if(bUseCurrencyFormat)
            {
                pGroupRow->SetFormatString(_T(" Subtotal "));
                pGroupRow->SetCurrencyFormat(&m_fmtCurrency);

            }
            else
            {
                pGroupRow->SetFormatString(_T(" Subtotal $=%.02f"));
            }
           
            pGroupRow->SetFormula(_T("SUMSUB(R*C1:R*C8)"));
            pGroupRow->SetCaption(_T("x"));

            bUseCurrencyFormat = !bUseCurrencyFormat;
        }
    }

    return FALSE;
}



You can initiate the m_fmtCurrency structure with different values to get the desired result.

Regards,
Artem Gontarenko
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 120
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 03 June 2019 at 9:23am
FYI. This changes will be available in next beta or final release.
ToolkitPro v19.0.0.050119 not contain this changes

Regards,
Artem Gontarenko
Back to Top
ylaroye View Drop Down
Groupie
Groupie


Joined: 01 November 2018
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote ylaroye Quote  Post ReplyReply Direct Link To This Post Posted: 03 June 2019 at 9:26am
Artem,

Thank you for your answer which corresponds to my waiting.
I am looking forward to the new version!

Yves Laroye
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.078 seconds.