void SMaskEdit::MaskDeleteSel() { if (m_nStartChar == m_nEndChar) return; SStringT strMaskedText = GetMaskedText(m_nEndChar); SetMaskedText(strMaskedText, m_nStartChar, FALSE); m_nEndChar = m_nStartChar; }
void SMaskEdit::InsertCharAt(int nPos, TCHAR nChar) { ASSERT(PosInRange(nPos)); if (!PosInRange(nPos)) return; SStringT strMaskedText = SStringT(nChar) + GetMaskedText(nPos); SetMaskedText(strMaskedText, nPos, FALSE); }
void SMaskEdit::DeleteCharAt(int nPos) { ASSERT(PosInRange(nPos)); if (!PosInRange(nPos)) return; SStringT strMaskedText = GetMaskedText(nPos + 1) + m_chPrompt; SetMaskedText(strMaskedText, nPos, FALSE); }
void CDxMaskEdit::InsertCharAt(int nPos, TCHAR nChar) { ATLASSERT(PosInRange(nPos)); if (!PosInRange(nPos)) return; CString strMaskedText = CString(nChar) + GetMaskedText(nPos); SetMaskedText(strMaskedText, nPos, FALSE); }
BOOL SMaskEdit::SetEditMask(LPCTSTR lpszMask, LPCTSTR lpszLiteral, LPCTSTR lpszDefault) { ASSERT(lpszMask); ASSERT(lpszLiteral); // initialize the mask for the control. m_strMask = lpszMask; m_strLiteral = lpszLiteral; ASSERT(m_strMask.GetLength() == m_strLiteral.GetLength()); if (m_strMask.GetLength() != m_strLiteral.GetLength()) return FALSE; if (lpszDefault == NULL) { m_strWindowText = m_strDefault = lpszLiteral; } else { m_strWindowText = m_strDefault = lpszDefault; if (m_strDefault.GetLength() != m_strLiteral.GetLength()) { SetMaskedText(m_strDefault, 0, FALSE); m_strDefault = m_strWindowText; } } ASSERT(m_strWindowText.GetLength() == m_strLiteral.GetLength()); // set the window text for the control. m_bModified = FALSE; SetWindowText(S_CT2W(m_strWindowText)); return TRUE; }