RAD Studio
Creating Actions in a VCL Forms Application

Using RAD Studio, the following procedure illustrates how to create actions using the ActionList tool. It sets up a simple application and describes how to create a file menu item with a file open action.  

Building the VCL application with ActionList actions consists of the following major steps:

  1. Create a main window and add tools for creating a main menu and a File open action.
  2. Add the File category to the main menu.
  3. Add the File open action to the File category.
  4. Build and run the application.

To create a main window

  1. Choose FileNewOtherDelphi Projects or C++Builder Projects and double-click the VCL Forms Application icon. The VCL Forms Designer displays.
  2. From the Standard category of the Tool Palette, add a TMainMenu and TActionList component to the form.
    Tip: To display icons for nonvisual components such as ActionList1, choose Tools->Options->Environment Options
    , select VCL Designer from the Delphi options, click Show Component Options, and click OK.

To add the File category to the main menu

  1. Double-click MainMenu1 on the form. The MainMenu1 editor displays with the first blank command category selected.
  2. In the Object Inspector, enter &File for the Caption property and press RETURN. File displays on the main menu.
  3. Click File on the MainMenu1 editor. The first blank action under the File command displays. Select the blank action.
  4. Double-click ActionList1 on the form. The ActionList editor displays.
  5. In the editor, select New Standard Action from the drop-down list to display the Standard Action Classes dialog.
  6. Scroll to the File category, and click the TFileOpen action.
  7. Click OK to close the dialog. File displays in the Categories listbox in the ActionList editor.
  8. Click File in the editor. The FileOpen1 action displays in the Action listbox.

To add the File Open action to the File category

  1. Double-click MainMenu1, if necessary, to display the MainMenu1 editor; select the blank action under the File category.
  2. In the Object Inspector, enter &Open for the Caption property and select FileOpen1 from the Action property drop-down list; then press RETURN. Open... displays in the blank action field in the MainMenu1 editor.

To build and run the application

  1. Choose RunRun. The application executes, displaying a form with the main menu bar and the File menu.
  2. Choose FileOpen in the application. The standard Open file dialog displays.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!