You can find the wpm sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples > CPP > VCL > Wpm
- Subversion Repository for C++: http://radstudiodemos.svn.sourceforge.net/viewvc/radstudiodemos/branches/RadStudio_XE2/CPP/VCL/Wpm
This application allows the user to enter text in a rich edit control in a minute and then to calculate the typing speed at the end. The amount of time elapsed is displayed using a progress bar. When the time has run out, the number of words per minute is displayed and the rich edit control becomes read-only.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open wpm.cbproj.
- Press F9 or choose Run > Run.
The project has one source file, wpmmain, which contains the class for the main form.
TFormMain represents the class for the main form. It contains a rich edit for text input, a timer to set the period of time in which the user can enter the text, a progress bar to display the amount of elapsed time, and two buttons to restart typing and to exit the application. TFormMain implements the method that calculates the average typing speed and the method that updates the progress bar as the time elapses.
- The OnTimer event handler updates the progress bar by calling the TProgressBar.StepIt method. TProgressBar.Max is set to 60 and the timer interval is set to 1000 milliseconds. Therefore, the total amount of time the user has to enter text is one minute.
- c_str is used with TRichEdit.Lines.Text to obtain the corresponding character array and to be able to use the  operator.
- isalnum is used to differentiate alphanumeric characters from separators.
- isalnum, __iscsym, iswalnum, _ismbcalnum