VCL.FindRep Sample
From RAD Studio Code Examples
Language:
This sample demonstrates how to use Find and Replace dialogs.
Contents |
Location
You can find the FindRep sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples > CPP > VCL > FindRep
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE4/CPP/VCL/FindRep/
Description
This application creates a form with a TRichEdit control and a Edit menu with two items: Find and Replace. Choose Find or Replace from the menu to find and replace text in the RichEdit control.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open FindRep.cbproj
- Press F9 or choose Run > Run
Files
The project has one source file, mainform.cpp, which contains the main form class.
Classes
- TFormMain, the class for the main form, handles the OnFind, OnReplace, and OnClick events of the FindDialog and ReplaceDialog components.
Implementation
- The main form contains a FindDialog and a ReplaceDialog component. They are executed when the user chooses Find or Replace from the menu. The OnFind and OnReplace events for these two dialogs are handled by the Find and Replace methods.
- SelText method is used so that the selected text in the RichEdit is the default string to find.
- TSearchTypes class is used to perform a search with two options: Match only whole words and Match case.