Creating Actions in a VCL Forms Application

From RAD Studio
Jump to: navigation, search

Go Up to How To Build VCL Forms Applications

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 File > New > Other > Delphi Projects or C++Builder Projects and double-click the VCL Forms Application icon.
    The VCL Form Designer displays.
  2. From the Standard category of the Tool Palette, add a TMainMenu and TActionList component to the form.

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 Run > Run. The application executes, displaying a form with the main menu bar and the File menu.
  2. Choose File > Open in the application. The standard Open file dialog displays.

See Also