[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Menus' (#lcl)

# TMenuItem

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

TMenuItem - The base structure of each item in a Menu.

## Declaration

Source position: menus.pp line 118

`type TMenuItem = class(TLCLComponent)`
`protected`
`FCommand: Word;` |  |
`protected`
`class procedure WSRegisterClass; override;` |  | WSRegisterClass - Register this Class for the current Widget Set
`protected`
`procedure ActionChange(); virtual;` |  | ActionChange - changes the action associated with this menu item to a new action
`procedure AssignTo(); override;` |  |
`procedure BitmapChange();` |  | BitmapChange - update the image associated with the menu item when the Bitmap has been changed
`function GetAction;` |  | GetAction - find the action associated with this menu item
`function GetActionLinkClass; virtual;` |  | GetActionLinkClass - find out what class of action link is associated with this menu item
`function GetHandle;` |  | GetHandle - get the operating system handle for the menu to which this item belongs
`procedure DoClicked(); message;` |  | DoClicked - process the system message signifying that a click has ocurred over this menu item
`procedure CheckChildrenHandles;`
`procedure CreateHandle; virtual;` |  | CreateHandle - create an operating system handle for this item
`procedure DestroyHandle; virtual;` |  | DestroyHandle - destroy the operating system handle and free space on the heap
`procedure Loaded; override;` |  |
`procedure Notification(); override;` |  |
`procedure GetChildren(); override;` |  |
`procedure InitiateActions;` |  | InitiateActions - start the initiation phase of the actions associated with the menu item
`procedure MenuChanged();` |  | MenuChanged - rebuild it if True
`procedure SetAction();` |  | SetAction - setup a new action associated with the menu item
`procedure SetChildOrder(); override;` |  |
`procedure SetGroupIndex();` |  | SetGroupIndex - write the index value for group to this item belongs (may write a new group)
`procedure SetImageIndex();` |  | SetImageIndex - gives the item an index value for its associated image
`procedure SetParentComponent(); override;` |  |
`procedure SetShortCut();` |  | SetShortCut - sets up the keyboard shortcut for this item
`procedure SetVisible();` |  | SetVisible - sets up whether the item is to be visible
`procedure UpdateImage;` |  | UpdateImage - freshen the image associated with the menu item, particularly if it has changed
`procedure UpdateImages;` |  | UpdateImages - update all images associated with the item
`procedure UpdateWSIcon;` |  | UpdateWSIcon - update the icon in the current Widget Set for this menu item
`procedure ImageListChange();` |  | ImageListChange - change the image list if commanded by the Sender
`property ActionLink: TMenuActionLink; [rw]` |  | ActionLink - a link to the action for this menu item
`public`
`FCompStyle: LongInt;` |  | FCompStyle - local variable holding value of CompStyle
`constructor Create(); override;` |  | Create - constructor for TMenuItem: calls inherited Create then intialises a large number of local variables
`destructor Destroy; override;` |  | Destroy - destructor for TMenuItem: releases bitmaps, handles, imagelists, actionlinks and parent controls, then calls inherited Destroy and
`function Find();` |  | Find the identity given menu item (named in ACaption)
`function GetEnumerator;`
`function GetImageList; virtual;` |  | GetImageList - Get the list of images for this menu, from which the image for the current item will be selected
`function GetParentComponent; override;` |  |
`function GetParentMenu; virtual;` |  | GetParentMenu - returns the parent menu to which this menu item belongs
`function GetIsRightToLeft; virtual;` |  | GetIsRightToLeft - find the value of the property determining whether right-to-left read/write is enabled
`function HandleAllocated;` |  | HandleAllocated - has an operating system handle been allocated?
`function HasIcon; virtual;` |  | HasIcon - is there an icon associated with this menu item?
`function HasParent; override;` |  |
`procedure InitiateAction; virtual;` |  | InitiateAction - start th einitiation phase of an action associated with the menu item
`procedure IntfDoSelect; virtual;` |  | IntfDoSelect - perform the selection using the interface
`function IndexOf();` |  | IndexOf - the index value of this item
`function IndexOfCaption(); virtual;` |  | IndexOfCaption - the index value of the caption for this item
`function VisibleIndexOf();` |  | VisibleIndexOf - the index of this item within the list of visible items
`procedure Add();` |  | Add - an item to the menu
`procedure AddSeparator;` |  | AddSeparator (a line) to the menu
`procedure Click; virtual;` |  | Click - simulate the OnClick event
`procedure Delete();` |  | Delete this item from the menu
`procedure HandleNeeded; virtual;` |  | HandleNeeded - tell the operating system that a handle is needed for this item
`procedure Insert();` |  | Insert a new item at the location marked by Index
`procedure RecreateHandle; virtual;` |  | RecreateHandle from the operating system
`procedure Remove();` |  | Remove this item from the menu
`function IsCheckItem; virtual;` |  | IsCheckItem - is there a check-box associated with this item?
`function IsLine;` |  | IsLine - if true, this item is a line (separator) on the menu
`function IsInMenuBar; virtual;` |  | IsInMenuBar - this item appears in the main menu bar
`procedure Clear;` |  | Clear - removes the contents of the item, but leaves the item in place
`function HasBitmap;` |  | HasBitmap - determines whether there is a Bitmap for this item
`function GetIconSize; virtual;` |  | GetIconSize - finds the size of the icon for this item
`procedure RemoveAllHandlersOfObject(); override;` |  | RemoveAllHandlersOfObject - method for removing all of an object's handlers: part of a clean-up procedure
`procedure AddHandlerOnDestroy();` |  | AddHandlerOnDestroy - add a handler for the OnDestroy event
`procedure RemoveHandlerOnDestroy();` |  | RemoveHandlerOnDestroy - remove a handler for the OnDestroy event
`procedure AddHandler();` |  | AddHandler - method to add a handler
`procedure RemoveHandler();` |  | RemoveHandler - method for removing a handler
`property Count: Integer; [r]` |  | Count - number of items
`property Handle: HMENU; [rw]` |  | Handle - the operating system handle for this item
`property Items: TMenuItem; default; [r]` |  | Items - the indexed list of menu items to which this item belongs
`property MenuIndex: Integer; [rw]` |  | MenuIndex - the index value of the menu to which this item belongs
`property Menu: TMenu; [r]` |  | Menu - the menu to which this item belongs
`property Parent: TMenuItem; [r]` |  | The Parent MenuItem from which this item is derived
`property Command: Word; [r]` |  | Command - the entry from the Command list to which this item refers
`function MenuVisibleIndex;` |  | MenuVisibleIndex - the index value of the visible menu
`procedure WriteDebugReport();` |  | WriteDebugReport - used in debugging
`published`
`property Action: TBasicAction; [rw]` |  | Action - the default action associated with this Menu Item
`property AutoCheck: Boolean; [rw]` |  | AutoCheck : Whether a check mark is automatically added when the item is selected
`property Caption: TTranslateString; [rws]` |  | Caption : The text that appears on the Menu Bar at run-time
`property Checked: Boolean; [rws]` |  | Checked : whether a check mark appears on the Menu Bar
`property Default: Boolean; [rw]` |  | Default : is this option the default selection? If so, it usually appears in Bold and is selected by hitting ENTER
`property Enabled: Boolean; [rws]` |  | Enabled : can this option be selected? If Not Enabled, usually 'greyed-out'
`property Bitmap: TBitmap; [rws]` |  | BitMap : an optional picture beside the MenuItem Caption
`property GroupIndex: Byte; [rw]` |  | GroupIndex : the sequence number in a group of mutually exclusive RadioItem choices
`property GlyphShowMode: TGlyphShowMode; [rw]`
`property HelpContext: THelpContext; [rws]` |  | HelpContext - an index to the context-sensitive help string to be used
`property Hint: TTranslateString; [rws]` |  | Hint : a pop-up help message that appears when the mouse hovers over an item.
`property ImageIndex: TImageIndex; [rws]` |  | ImageIndex - number in a list of images for use in illustrating menu items
`property RadioItem: Boolean; [rw]` |  | RadioItem : whether the item is part of a group of mutually exclusive choices.
`property RightJustify: Boolean; [rw]` |  | RightJustify : the position of the Caption in the Menu Panel. Default (False) is Left Justify
`property ShortCut: TShortCut; [rws]` |  | ShortCut - the quick key sequence to be used in selecting this menu item
`property ShowAlwaysCheckable: Boolean; [rw]` |  | ShowAlwaysCheckable - if True, Item is always shown as checkable
`property SubMenuImages: TCustomImageList; [rw]` |  | SubMenuImages - will images be shown for sub-menu items as well as the main item?
`property Visible: Boolean; [rws]` |  | Visible - can the item be seen?
`property OnClick: TNotifyEvent; [rws]` |  | OnClick - event handler for selection of this menu item
`end;`

## Inheritance

`TMenuItem` |  | TMenuItem - The base structure of each item in a Menu.
`TLCLComponent` |  | TLCLComponent - base class for LCL components
`TComponent,IUnknown,IInterfaceComponentReference`
`TPersistent`
`TObject`

## Description

TMenuItem - The base structure of each item in a Menu.

This Component does the hard work of processing the Items found in the various types of menus. It defines a lot of the properties and methods used in the various sorts of menu, including TMainMenu, TMenu and TPopUpMenu

The latest version of this document can be found at lazarus-ccr.sourceforge.net.