VCL.ActionBands Sample
This sample exemplifies how to use actions, action lists, and action managers.
Contents |
Location
You can find the WordPad sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples and then navigate to either:
- Delphi\VCL\ActionBands
- CPP\VCL\ActionBands
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE4/Delphi/VCL/ActionBands/
- Subversion Repository for C++: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE4/CPP/VCL/ActionBands/
Description
The application represents a small text editor, which provides basic editing functionalities: formatting, cutting, copying, searching/replacing, saving to file, opening from file, and changing the style of the editor.
The main form contains three toolbars and a menu bar with items corresponding to the features mentioned above. For entering the text, a TRichEdit component is used. An ActionManager and an ActionList are used for handling the actions mapped to the menu and toolbar items. For example, Edit > Paste is implemented by an instance of the standard action TEditPaste and inherits its ShortCut.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open WordPad.dproj.
- Press F9 or choose Run > Run.
Files
The project has one source file, main.pas, which contains the form class.
Classes
TForm1, the form class, handles the visual and nonvisual components and provides implementation for the methods that are called when the actions are executed.
Implementation
- The application adds the styles to the menu at run time. In the Form’s OnCreate event handler, all the styles available are retrieved from the global variable ActionBarStyles and the corresponding actions are created and added to the action list and the menu.
- The application also uses a custom action, ShadowActn, derived directly from TAction.
Uses
- ActionList
- ActionManager
- TFileSaveAs
- TFileRun
- TFileExit
- TSearchFind
- TSearchFindNext
- TSearchReplace
- TSearchFindFirst
- TRichEdit
- TImageList
- TStatusBar
- TAction
- TActionToolBar
- TEditCut
- TEditCopy
- TEditPaste
- TEditDelete
- TEditSelectAll
- TEditUndo
- TRichEditBold
- TRichEditItalic
- TRichEditUnderline
- TRichEditBullets
- TRichEditAlignLeft
- TRichEditAlignRight
- TRichEditAlignCenter
- TForm.OnCreate
- ActionBarStyles