RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Creating Actions in a VCL Forms Application

Using RAD Studio, the following procedures illustrate how to create actions using the ActionList tool. You will set up a simple application and create an edit menu with cut and paste actions that can be used to cut and paste to a memo.  

Creating the VCL application consists of the following major steps:

  1. Add main menu, actionlist, and memo tools to a form.
  2. Create the cut and paste actions.
  3. Add the actions to the main menu and associate with the edit action category.
  4. Build and run the application.

To add the main menu, actionlist, and memo to a form

  1. Choose FileNewOtherDelph for .NET ProjectsVCL Forms Application to create a new form.
  2. Click the Design tab to switch to the VCL Form Designer.
  3. From the Standard category of the Tool Palette, place a TMainMenu, TActionList, and TMemo component on the form.

To create the actions

  1. Double-click ActionList1 on the form. The ActionList Editor displays.
  2. Select New Standard Action from the drop-down list to display the Standard Action Classes dialog box.
  3. Scroll to the TEditCut action, select it, and click OK. EditCut1 displays in the Actions list in the editor.
  4. Select New Standard Action from the drop-down list to display the Standard Action Classes dialog box.
  5. Scroll to the TEditPaste action, select it, and click OK. EditPaste1 displays in the Actions list in the editor.
  6. Close the ActionList Editor window.

To add the cut and paste actions to the edit category in 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 Edit for the Caption property and press ENTER. Edit displays as the first command category.
  3. Click Edit to display a blank action just below it.
  4. Click the blank action to select it.
  5. In the Object Inspector, select EditCut1 from the drop-down list of actions in the Action property, located in the Linkage category.
  6. If not already filled in, expand the list of Action properties, enter Cut for the Caption property, enter Edit for the category, and press ENTER. Cut displays as the first action.
  7. In the MainMenu1 Editor, click the second blank action beneath Cut to select it.
  8. In the Object Inspector, select EditPaste from the drop-down list of actions in the Action property, located in the Linkage category.
  9. Expand the list of Action properties, and if necessary, enter Paste for the Caption property, enter Edit for the category, and press ENTER. Paste displays as the second action.

To build and run the application

  1. Save all files in the project.
  2. Choose RunRun. The application executes, displaying a form with the main menu bar and the Edit menu.
  3. In the application, select text in the memo.
  4. Choose EditCut. The text is cut from the memo.
  5. Choose EditPaste. The text is pasted back into the memo.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!