Hi;
If you call SetDateFormat with an empty string, the format used will be the system date format:
CXRReportRecordItemDateTime* pDt=DYNAMIC_DOWNCAST(CXRReportRecordItemDateTime, AddItem(new CXRReportRecordItemDateTime(COleDateTime(dtCreated)))); pDt->SetFormatString(_T(""));
or you can create your own date item and use system API function to build the format strings like this:
IMPLEMENT_DYNAMIC(CCustomItemDateEdit, CXTPPropertyGridItemDate)
CCustomItemDateEdit::CCustomItemDateEdit(LPCTSTR strCaption, const COleDateTime& oleDate) : CXTPPropertyGridItemDate(strCaption, oleDate) { Init(); }
CCustomItemDateEdit::CCustomItemDateEdit(UINT uiID, const COleDateTime& aDate) : CXTPPropertyGridItemDate(uiID, aDate) { Init(); }
CCustomItemDateEdit::~CCustomItemDateEdit() { }
void CCustomItemDateEdit::Init() { TCHAR lpIDate[2]; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDATE, lpIDate, _countof(lpIDate)); int iDateOrder=_ttoi(lpIDate); CString strFormat, strMaskFmt, strLiteralFmt; if (iDateOrder==0) // Month-Day-Year { strFormat=_T("%%m%s%%d%s%%Y"); strMaskFmt=_T("00%s00%s0000"); strLiteralFmt=_T("__%s__%s____"); } else if (iDateOrder==1) // Day-Month-Year { strFormat=_T("%%d%s%%m%s%%Y"); strMaskFmt=_T("00%s00%s0000"); strLiteralFmt=_T("__%s__%s____"); } else if (iDateOrder==2) // Year-Month-Day { strFormat=_T("%%Y%s%%m%s%%d"); strMaskFmt=_T("0000%s00%s00"); strLiteralFmt=_T("____%s__%s__");
}
TCHAR lpsDate[4]; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDATE, lpsDate, _countof(lpsDate)); m_strFormat.Format(strFormat, lpsDate, lpsDate); CString strMask, strLiteral; strMask.Format(strMaskFmt, lpsDate, lpsDate); strLiteral.Format(strLiteralFmt, lpsDate, lpsDate); SetMask(strMask, strLiteral);
SetDate(GetDate()); }
CString CCustomItemDateEdit::Format(const COleDateTime& oleDate) { if (oleDate.GetStatus() != COleDateTime::valid) return _T("");
return oleDate.Format(VAR_DATEVALUEONLY); }
------------- Martin
Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022
|