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