Hide

SftMask/OCX 7.0 - ActiveX Masked Edit Control

Display
Print

Fmt1 Sample (C++)

This sample illustrates date, time and number formatting.

This is not an executable sample, so a complete project is not provided. These statements are intended to show basic concepts and the syntax used.

BOOL CProject1Dlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    m_pMask1 = m_Mask1.GetControlUnknown();
    _ASSERT(m_pMask1 != NULL);

    CComBSTR FmtVal;
    m_pMask1->Calculator->FormatCurrency(48533.85, -1, -1, -1, _bstr_t(_T("")), _bstr_t(_T("")), -1, -1, _bstr_t(_T("")), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("short");
    m_pMask1->Calendar->FormatDate(COleDateTime(2000, 8, 1, 0,0,0), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("long");
    m_pMask1->Calendar->FormatDate(COleDateTime(2000, 8, 1, 0,0,0), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("dddd, MMMM d 'in the year' yyyy");
    m_pMask1->Calendar->FormatDate(COleDateTime(2000, 8, 1, 0,0,0), &FmtVal);
    AfxMessageBox(CString(FmtVal));


    m_pMask1->Calculator->FormatNumber(48533.85, -1, -1, -1, _bstr_t(_T("")), _bstr_t(_T("")), -1, &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("");
    m_pMask1->Calendar->FormatTime(COleDateTime(2000, 8, 1, 5, 1, 59), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    FmtVal = _T("'Hour='H 'Mins='m 'Secs='s");
    m_pMask1->Calendar->FormatTime(COleDateTime(2000, 8, 1, 5, 1, 59), &FmtVal);
    AfxMessageBox(CString(FmtVal));

    short Year, Month, Day, DayOfWeek;
    m_pMask1->Calendar->GetDateInfo(COleDateTime(2000, 7, 14, 5,49,23), &Year, &Month, &Day, &DayOfWeek);
    CString str;
    str.Format(_T("Year=%d Month=%d Day=%d DayOfWeek=%d"), Year, Month, Day, DayOfWeek);
    AfxMessageBox(str);

    short Hours, Minutes, Seconds;
    m_pMask1->Calendar->GetTimeInfo(COleDateTime(2000, 7, 14, 5,49,23), &Hours, &Minutes, &Seconds);
    str.Format(_T("Hours=%d Minutes=%d Seconds=%d"), Hours, Minutes, Seconds);
    AfxMessageBox(str);

    return TRUE;
}

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.