RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TComponentEditor.PrepareItem Method

Allows the component editor to modify menu items as they are added to the context menu.

Pascal
procedure PrepareItem(Index: Integer; const AItem: IMenuItem); virtual;
C++
virtual __fastcall PrepareItem(int Index, const IMenuItem AItem);

The form designer calls PrepareItem for each verb when it constructs the context menu. This method lets the component editor make any modifications to the menu item for each verb, including adding subitems or removing the item from the context menu. 

Index identifies the current verb that the form designer is adding to the context menu. This is the same index as appears for the command in the GetVerb and ExecuteVerb methods. 

AItem is an interface to the menu item created by the form designer for the current verb. To add subitems, call the AddItem method of this interface. To disable the item, set the Enabled property to false. To suppress the menu item altogether, set its Visible property to false. 

As implemented in TComponentEditor, PrepareItem does nothing. Override this method to customize the context menu before it is displayed. 

 

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