Hide

SftMask/OCX 7.0 - ActiveX Masked Edit Control

Display
Print

Sample4 Sample (C++)

This sample illustrates input validation.

The source code is located at C:\Program Files (x86)\Softelvdm\SftMask OCX 7.0\Samples\VC++\Sample4\Sample4Dlg.cpp or C:\Program Files\Softelvdm\SftMask OCX 7.0\Samples\VC++\Sample4\Sample4Dlg.cpp (on 32-bit Windows versions).

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

    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);            // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon

    // set up variables for all SftMask/OCX controls
    m_vSftMaskName = m_CtlName.GetControlUnknown();
    _ASSERT(m_vSftMaskName != NULL);
    m_vSftMaskCompany = m_CtlCompany.GetControlUnknown();
    _ASSERT(m_vSftMaskCompany != NULL);
    m_vSftMaskZIP = m_CtlZIP.GetControlUnknown();
    _ASSERT(m_vSftMaskZIP != NULL);
    m_vSftMaskDate = m_CtlDate.GetControlUnknown();
    _ASSERT(m_vSftMaskDate != NULL);
    m_vSftMaskTelephone = m_CtlTelephone.GetControlUnknown();
    _ASSERT(m_vSftMaskTelephone != NULL);
    m_vSftMaskAmount = m_CtlAmount.GetControlUnknown();
    _ASSERT(m_vSftMaskAmount != NULL);

    return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSample4Dlg::OnCustomValidationSftMaskZip(BOOL FAR* Cancel)
{
    if (m_vSftMaskZIP->Text != _bstr_t("11111")) {
        *Cancel = TRUE;
    }
}

void CSample4Dlg::OnOK()
{
    if ((m_vSftMaskName->Contents->GetValid() == VARIANT_TRUE) &
            (m_vSftMaskCompany->Contents->GetValid() == VARIANT_TRUE) &
            (m_vSftMaskZIP->Contents->GetValid() == VARIANT_TRUE) &
            (m_vSftMaskDate->Contents->GetValid() == VARIANT_TRUE) &
            (m_vSftMaskTelephone->Contents->GetValid() == VARIANT_TRUE) &
            (m_vSftMaskAmount->Contents->GetValid() == VARIANT_TRUE)) {
        CDialog::OnOK();
    } else {
        ::MessageBox(NULL, _T("There are validation errors - Please correct the data entered."), _T("Form Errors & Warnings"), MB_OK|MB_TASKMODAL);
    }
}

BEGIN_EVENTSINK_MAP(CSample4Dlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CSample4Dlg)
    ON_EVENT(CSample4Dlg, IDC_SFTMASKZIP, 9 /* CustomValidation */, OnCustomValidationSftMaskZip, VTS_PBOOL)
    //}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

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