An action manager is a central point from which you create and maintain the actions of an application. As reviewed for an action list, an action manager holds all the actions commonly used by a main menu, one or more toolbars, and other action-based controls such as buttons.
To give you a common area to manage actions, the VCL provides an action manager through a class named TActionManager. To visually create an action manager, in the Additional section of the Tool Palette, click the TActionManager button and click the form or a container. The TActionManager class is based on the TCustomActionManager class, which itself is derived from TCustomActionList, which is the same parent as the TActionList class. Like an action list, an action manager can benefit from an image list. Therefore, before configuring an action manager, create and add an image list to your application. You don't even have to add images to it. After creating an image list, to assign it to an action manager, access the Object Inspector for the action manager and select the image list from its Images field.
After adding an action manager to a form or container, you should (must) create its action. To do this visually:
Any of these action would open the Editon ActionManager dialog box:
From the Editing ActionManager, to create an action:
After creating an action, to configure it, click it in the Editing dialog box and use the options in the Object Inspector. The actions of an action manager are primarily the same as those of an action list. This means that each action is an object of type TAction, which is represented in the Actions property of the TCustomActionList class, the collection class that holds the items of the list. As mentioned for an action list, the VCL ships with an impressive collection of ready-made actions. To get them, in the Editing dialog box:
You configure the action using the exact same techniques of the action list.
When creating an SDI or an MDI application, if you want to mange its menu(s) and/or toolbar(s), you should use an action because we saw that it provides a convenient central point. To make this possible, the VCL provides an object named an action menu bar. It is an object to which you primarily add the desired menu items using the objects available from an action manager, which is extremely create to create. The advantage is convenience of maintenance.
The action main menu is available through a class named TActionMainMenuBar. To get it, in the Additional section of the Tool Palette, click the TActionMainMenuBar button and click the form. You must then assign it to an action manager. This is visually done in the Object Inspector where you would select the TActionManager object in the ActionManager property of the TActionMainMenuBar object. After associating the action manager to the action main menu, to manage it, you use the Editing dialog box. To visually do this, on the form or container, double-click the TActionManager object. To create a top menu item, in the Categories list of the Editing ActionManager dialog box, drag the desired category and drop it in the main menu area on the form. To configure a menu item, click it on the main menu to select it. Then use the Object Inspector and change the desired options. The Editing ActionManager dialog box allows you to change the order (or sequence) of items in the Actions list. If you drag a category from the Categories list and drop it on the main menu of your form, the order of items would be kept. If you change the order of items in the Editing ActionManager dialog box, the main menu on your form would not be automatically changed. In the same way, if you add a new item to a group in the Editing ActionManager dialog box, the main menu on your form will not be updated. To solve this problem, you have two options. If you have not written any code for the menu items, you can simply delete the whole menu category on the main menu of the form. The other potion, which is better, is to drag the new item from the Editing ActionManager dialog box and drop it in the appropriate category on the main menu of your form. The Editing ActionManager dialog box does not allow you to create separators. To create a separator, in the bottom section of the Editing ActionManager, drag the Drag To Create Separator button and drop it in the desired section on the main menu on your form.
An action is primarily a normal toolbar. The "action" addition indicates that the object can be managed through an action list, allowing you to perform programmatic operations from a central object. Probably the main advantage is that, as seen with the user of an action list, an action toolbar can use the same objects as an action main menu; that is, the actions are stored in an action manager that takes over the whole concern about the common functionalities of objects.
To support action toolbars, the VCL provides the TActionToolBar class. To visually create it, in the Additional section of the Tool Palette, click the TActionToolBar button and click the form. You use an action toolbar through an action manager. Therefore, after creating an action toolbar, to visually specify its action manager, in the Object Inspector, click the ActionManager field and select the action manager object. To configure an action toolbar, you use the action manager. After assigning an action manager to an action toolbar, on the form, right-click the action manager and click Customize. To add action to the toolbar, drag that action from the Actions list of the Editing ActionManager dialog box and drop it on the toolbar in the form. As mentioned for the action main menu, if you want to add a separator to a toolbar, drag the Drag To Create Separator button and drop it in the desired spot on the toolbar on your form.
Most modern SDI and MDI applications that include menus and dialog box give you options to customize the menu items and the buttons on toolbars. Here is an example: the Customize dialog box from Embarcadero RAD Studio:
A Customize dialog box allows you to add items and/or buttons, move items and/or button, or remove (or hide the objects. A Customize dialog box is usually made of three property pages that contain the actions and options that can be configured. The functionality of a Customize dialog box is usually too complex and tiresome to implement: not in the VCL.
To help you create a Customize dialog box, the VCL includes a class and control named TCustomizeDlg. During design, to get it, in the Additional section of the Tool Palette, click the TCustomizeDlg button and click the form or a container.
When you have equipped your application with a Customize dialog box, you should create a menu item or a button from which the user can display it. To let you display the Customize dialog box, the TCustomizeDlg class is equipped with a method named Show. Its syntax is: void __fastcall Show(void); As you can see, this method takes no argument and doesn't do anything significant other that displaying the dialog box. Also notice that, based on its name, the dialog box would be displayed as modeless object. When you call the Show() method, the dialog box fires an OnShow event. This event is of type TNotifyEvent.
To make it easy to implement its functionality, a TCustomizeDlg object needs an action manager. Therefore, before configuring it, first create an action manager. The action manager doesn't have to be complete. That is, you can start it and change it little by little. After creating an action manager, to let you assign it to a Customize dialog box, the TCustomizeDlg class is equipped with a property named ActionManager, which is of type TCustomActionManager, the parent of the TActionManager class: __property Actnman::TCustomActionManager * ActionManager = {read=FActionManager, write=SetActionManager}; To visually specify the action manager of the Customize dialog box, access its Object Inspector and select the object from the ActionManager field.
A Customize dialog box must be a modeless dialog box in order to accomplish its role. That is, the parent application of a Customize dialog box must be "physically" accessible while the dialog box is displaying. To make this possible, the TCustomizeDlg class is equipped with a Boolean property named StayOnTop: __property bool StayOnTop = {read=FStayOnTop,write=SetStayOnTop};
After using the dialog box, the user can close it by clicking its system Close button. When this happens, the dialog box fires an OnClose event, which is of type TNotifyEvent. If necessay, you can use this event to take any action when the user decides to close the object. |
|
|||||||||||||||||||||||||||||||||||||||||||||||||
|