Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Toolkit User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.5 Basic Tutorial—MaskEdit Control

The CEdit control that MFC provides is often insufficient for data entry purposes. The application can only verify the value the user entered after it is fully typed. In addition, CEdit provides no ability to break the edit field into sub-fields that indicate what text is expected. SECMaskEdit addresses these problems. SECMaskEdit is derived from CEdit and it adds member functions for specifying a mask.

This tutorial uses the built-in functionality of Objective Toolkit's SECMaskEdit class to create a masked edit field for a telephone number.

Follow the steps below to create a simple dialog-based application using the AppWizard. An SECMaskEdit object, added as a member of the dialog, displays an entry field that is formatted for a telephone number. Along the way, the application is given access to all the Objective Toolkit classes.

  1. From the File menu, choose New... (Name your project application MaskPhone.)

  2. From the main wizard dialog, select MFC AppWizard (exe).

  3. Click the Dialog based radio button.

  4. Click Finish. The MFC AppWizard finishes creating the project for you.


    You must follow the two additional steps below if you are going to generate your own sample programs.

  5. The next thing we need to do is make sure all of the resources in Objective Toolkit are available to your project. Find the stdafx.h file for the project and add the following line:

    Make sure the stdafx.h file reads:

  6. Click View | Resource Includes… and add the following line to the Read-Only symbol directives list box:

    In the same dialog, add the following line to the compile-time directives list box:

    The list boxes should look like the following:

  7. Click OK. A message box with a warning appears on the screen. The wording may vary depending on the version of Visual Studio, but the appearance of the warning is standard.

    Create the dialog box for the control. In the Resources view, open the Dialog folder. It holds IDD_MASKPHONE_DIALOG. Open it and remove the static text that is already there.

    Replace the text with an Edit box from the Controls palette. Right-click the edit box and open the properties dialog. Name the edit box IDC_PHONE_NUMBER.

  8. Add a member variable of SECMaskEdit to the dialog class. Open up the header file for MaskPhoneDlg and look up OnInitDialog(). Add the following line:

  9. Open MaskPhoneDlg.cpp, look up OnInitDialog(), and the add the following code to it under the TODO comment.

  10. Build the project and see the final dialog.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.