RAD Studio |  |

Registering Actions
See Also
Collapse All

When you write your own actions, you can register actions to enable them to appear in the Action List editor. You register and unregister actions by using the global routines in the Actnlist unit:

Copy Code

    procedure RegisterActions(const CategoryName: string; const AClasses: array of TBasicActionClass; Resource: TComponentClass);
    procedure UnRegisterActions(const AClasses: array of TBasicActionClass);

Copy Code

    extern PACKAGE void __fastcall UnRegisterActions(TMetaClass* const * AClasses, const int AClasses_Size);

Copy Code

    extern PACKAGE void __fastcall RegisterActions(const AnsiString CategoryName, TMetaClass* const * AClasses, const int AClasses_Size, TMetaClass* Resource);

When you call RegisterActions, the actions you register appear in the Action List editor for use by your applications. You can supply a category name to organize your actions, as well as a Resource parameter that lets you supply default property values.

For example, the following code registers the standard actions with the IDE:

Copy Code

    { Standard action registration }
    RegisterActions('', [TAction], nil);
    RegisterActions('Edit', [TEditCut, TEditCopy, TEditPaste], TStandardActions);
    RegisterActions('Window', [TWindowClose, TWindowCascade, TWindowTileHorizontal, TWindowTileVertical, TWindowMinimizeAll, TWindowArrange], TStandardActions);

Copy Code

    namespace MyAction
    {
      void __fastcall PACKAGE Register()
      {
         // code goes here to register any components and editors
    TMetaClass classes[2] = {__classid(TMyAction1), __classid(TMyAction2)};
    RegisterActions("MySpecialActions", classes, 1, NULL);
    }
    }

When you call UnRegisterActions, the actions no longer appear in the Action List editor.

See Also

TActionList

TAction

TActionLink

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!