Creating Actions in a Windows VCL Application
Go Up to How To Build Windows VCL 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:
- Create a main window and add tools for creating a main menu and a file open action.
- Add the File category to the main menu.
- Add the file open action to the File category.
- Build and run the application.
To create a main window
- Choose File > New > Windows VCL Application - Delphi or Windows VCL Application - C++ Builder.
- 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
- Double-click MainMenu1 on the form. The MainMenu1 editor displays with the first blank command category selected.
- In the Object Inspector, enter &File for the Caption property and press RETURN. File displays on the main menu.
- Click File on the MainMenu1 editor. The first blank action under the File command displays. Select the blank action.
- Double-click ActionList1 on the form. The ActionList editor displays.
- In the editor, select New Standard Action from the drop-down list to display the Standard Action Classes dialog.
- Scroll to the File category, and click the TFileOpen action.
- Click OK to close the dialog. File displays in the Categories listbox in the ActionList editor.
- Click File in the editor. The FileOpen1 action displays in the Action listbox.
To add the File Open action to the File category
- Double-click MainMenu1, if necessary, to display the MainMenu1 editor; select the blank action under the File category.
- 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
- Choose Run > Run. The application executes, displaying a form with the main menu bar and the File menu.
- Choose File > Open in the application. The standard Open file dialog displays.