This sample illustrates phone number entry.
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);
m_pMask1->Caption->SizePercent = 33;
m_pMask1->Caption->Text = _T("&Text:");
m_pMask1->Mask = _T("\\(###\\) ###\\-####");
m_pMask1->Alignment = alignSftMaskLeft;
m_pMask1->BackColorInvalid = RGB(255,0,0);
m_pMask1->ForeColorInvalid = RGB(255,255,255);
m_pMask1->FormattedText = _T("Please enter a telephone number");
return TRUE;
}
void CProject1Dlg::OnChangeSftMask1()
{
if (m_pMask1->Contents->Valid != VARIANT_FALSE) {
AfxMessageBox(_T("This is a valid phone number."));
} else {
if (m_pMask1->Contents->Empty != VARIANT_FALSE)
m_pMask1->FormattedText = _T("Please enter a telephone number");
else
m_pMask1->FormattedText = _T("");
}
}
BEGIN_EVENTSINK_MAP(CProject1Dlg, CDialog)
//{{AFX_EVENTSINK_MAP(CProject1Dlg)
ON_EVENT(CProject1Dlg, IDC_SFTMASK1, 8 /* Change */, OnChangeSftMask1, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()