BCGControlBar Pro for MFC
void CBCGPMaskEdit::EnableMask ( LPCTSTR  lpszMask,
LPCTSTR  lpszInputTemplate,
TCHAR  chMaskInputTemplate = _T('_'),
LPCTSTR  lpszValid = NULL 
)

Sets up the mask.

Use this member function to set up the mask for the edit control.

The default implementation uses the following characters for mask:

  • D Digit only
  • d Digit or space
  • + '+' or '-' or space
  • C Alpha only
  • c Alpha or space
  • A Alphanumeric only
  • a Alphanumeric or space

You can derive a class from CBCGPMaskEdit and override IsMaskedChar() for the custom mask processing.

Parameters
lpszMaskThe mask string specifies what type of characters can be written and where.
lpszInputTemplateThe mask template string. It's length must be the same as lpszMask's length. '_' symbols is used as a character placeholder.
chMaskInputTemplateSpecifies the default character.
lpszValidSpecifies a string which is interpreted as a set of valid characters.

Examples of EnableMask:

Copy
// Mask : phone number
m_wndMaskEdit.EnableMask(
L" ddd ddd dd dd", // The mask string
L"(___) ___-__-__", // Literal, "_" char = character entry
' '); // Default char
m_wndMaskEdit.SetValidChars(NULL); //Valid string characters
m_wndMaskEdit.SetWindowText(L"(812) 212-85-06");
// Mask: State,ZipCode
m_wndMaskEdit.EnableMask(
L" cc ddddd-dddd", // The mask string
L"State: __, Zip:_____-____", // Literal, "_" char =character entry
' '); // Backspace replace char
m_wndMaskEdit.SetValidChars(NULL); // Valid string characters
m_wndMaskEdit.SetWindowText(L"State: MI, Zip:12345-6789");