VCL.ActionBands Sample

From RAD Studio XE2 Code Examples
Jump to: navigation, search

Language:

This sample exemplifies how to use actions, action lists, and action managers.

Contents

Location

You can find the WordPad sample project at:

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

  1. Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open WordPad.dproj.
  2. 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

See Also

Personal tools
Previous Versions