Show: Delphi C++
Display Preferences

Handling VCL Actions Using an Action Manager

From RAD Studio
Jump to: navigation, search

Go Up to VCL Actions


You can handle the actions of your applications using an action manager component.

This is the simplest and the most powerful approach. However, if you think that you may want to migrate your application to FireMonkey in the future, consider using an action list component instead, which is how you handle actions in FireMonkey applications.

The Action Manager makes it easy to define and group actions, create different layouts, and customize menus at design time or run time. You use the Action Manager to automatically generate toolbars and main menus based on the actions contained in your application. The Action Manager manages standard actions and any custom actions that you have written. You then create UI elements based on these actions and use action bands to render the actions items as either menu items or as buttons on a toolbar.

The general procedure for creating menus, toolbars, and other action bands involves these steps:

  • Drop an Action Manager onto a form.
  • Add actions to the Action Manager, which organizes them into appropriate action lists.
  • Create the action bands (that is, the menu or the toolbar) for the user interface.
  • Drag and drop the actions into the application interface.

The following procedure explains these steps in more detail.

To create menus and toolbars using action bands

  1. From the Additional category of the Tool palette, drop an Action Manager component (Vcl.ActnMan.TActionManager) onto the form where you want to create the toolbar or menu.
  2. If you want images on the menu or toolbar, drop an ImageList component from the Win32 category of the Tool palette onto a form. (You need to add the images you want to use to the ImageList or use the one provided.)
  3. From the Additional category of the Tool palette, drop one or more of the following action bands onto the form:
  4. Connect the ImageList to the Action Manager: with focus on the Action Manager and in the Object Inspector, select the name of the ImageList from the Images property.
  5. Add actions to the action pane of the Action Manager editor:
    • Double-click the Action Manager to display the Action Manager editor.
    • Click the drop-down arrow next to the New Action button (the leftmost button at the top right corner of the Actions tab) and select New Action or New Standard Action. A tree view is displayed. Add one or more actions or categories of actions to the action pane of the Action Manager. The Action Manager adds the actions to its action lists.
  6. Drag and drop single actions or categories of actions from the Action Manager editor onto the menu or toolbar you are designing.

To add user-defined actions, create a new TAction by pressing the New Action button and writing an event handler that defines how it will respond when fired. See What Happens When an Action Fires for details. Once you've defined the actions, you can drag and drop them onto menus or toolbars like the standard actions.

Topics

See Also

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance