Registering Actions
Go Up to Handling VCL Actions Using an Action List
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 System.Actions.RegisterActions and System.Actions.UnRegisterActions:
procedure RegisterActions(const CategoryName: string;
const AClasses: array of TBasicActionClass;
Resource: TComponentClass);
procedure UnRegisterActions(
const AClasses: array of TBasicActionClass);
extern PACKAGE void __fastcall RegisterActions(
const AnsiString CategoryName,
TMetaClass* const * AClasses, const int AClasses_Size,
TMetaClass* Resource);
extern PACKAGE void __fastcall UnRegisterActions(
TMetaClass* const * AClasses,
const int AClasses_Size);
When you call System.Actions.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:
{ Standard action registration }
RegisterActions('', [TAction], nil);
RegisterActions('Edit',
[TEditCut, TEditCopy, TEditPaste],
TStandardActions);
RegisterActions('Window',
[TWindowClose, TWindowCascade, TWindowTileHorizontal,
TWindowTileVertical, TWindowMinimizeAll, TWindowArrange],
TStandardActions);
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 System.Actions.UnRegisterActions, the actions no longer appear in the Action List editor.