delphitactionmanager

How to disable menu, sub-menu in ActionMainMenuBar?


Using: Delphi XE3, VCL Forms application

I have a menu containing a sub-menu in a ActionMainMenuBar. How can I via code:

  1. disable the menu
  2. disable the sub-menu

Solution

    1. Create a 'TAction' per menu/submenu that you want to enable disable. Do not assign them to any category.

    2. Create an 'OnExecute' event handler for these actions, so that these can be enabled. You don't have to put any code in the handler, a comment ('//') is enough for the IDE to not to delete the handlers.

    3. Select the 'TActionClient' that represents the menu/submenu from the form designer, just click on the item.

    4. Assign one of the actions to its 'Action' property in the object inspector.

    5. Enable/disable the action associated with the 'TActionClient' that represents the menu/submenu at run time for the menu/submenu to be enabled/disabled accordingly.