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

TMenuItem

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

Represents a menu item displayed in a menu.

Declaration

Source position: menus.pp line 147

type TMenuItem = class(TLCLComponent)

protected

  FCommand: Word;

  

Stores the numeric command in the widgetset class for the menu item.

  class procedure WSRegisterClass; override;

  

Registers this component class with the current WidgetSet.

  procedure ActionChange(); virtual;

  

Changes the action for the menu item using the value specified in Sender.

  procedure AssignTo(); override;

  

Copies property values from the current class instance to the specified destination.

  procedure BitmapChange();

  

Updates the image associated with the menu item when it has been changed.

  function DoDrawItem(); virtual;

  

Performs actions needed to draw the menu item to the specified Canvas.

  function DoMeasureItem(); virtual;

  

Performs actions needed to get the width and height for the menu item.

  function GetAction;

  

Gets the value for the Action property.

  function GetActionLinkClass; virtual;

  

Gets the class reference used to create an action link for the class.

  function GetHandle;

  

Gets the value for the Handle property.

  procedure DoClicked(); message;

  

DoClicked- process the system message signifying that a click has occurred over this menu item.

  procedure CheckChildrenHandles;

  

Verifies the handles for child menu items on the menu.

  procedure CreateHandle; virtual;

  

Creates the Handle for the menu item.

  procedure DestroyHandle; virtual;

  

Frees the Handle for the control and any handles allocated for its Items.

  procedure Loaded; override;

  

Performs actions needed after the component is loaded using LCL streaming.

  procedure Notification(); override;

  

Performs a notification when the menu item is added or removed.

  procedure GetChildren(); override;

  

Performs an operation for a component instance and its Items.

  procedure InitiateActions;

  

Updates Actions in child menu items.

  procedure MenuChanged();

  

Signals the OnChange event handler (when assigned) and optionally rebuilds child menu items.

  procedure SetAction();

  

Sets the value for the Action property.

  procedure SetChildOrder(); override;

  

Moves a menu item to the specified position in a menu.

  procedure SetGroupIndex();

  

Sets the value for the GroupIndex property.

  procedure SetImageIndex();

  

Sets the value for the ImageIndex property.

  procedure SetParentComponent(); override;

  

Ensures that the menu item is parented by the specified menu or menu item.

  procedure SetShortCut();

  

Sets the value for the ShortCut property.

  procedure SetShortCutKey2();

  

Sets the value for the ShortCutKey2 property.

  procedure SetVisible();

  

Sets the value for the Visible property.

  procedure UpdateWSIcon;

  

Updates the widgetset class with the values in HasIcon and Bitmap.

  procedure ImageListChange();

  

Implements the event handler signalled when SubMenuImages property has been updated.

  property ActionLink: TMenuActionLink; [rw]

  

Contains the link to the Action for the menu item.

public

  FCompStyle: LongInt;

  

Member used to store style flags for the component.

  constructor Create(); override;

  

Constructor for the class instance.

  destructor Destroy; override;

  

Destructor for the class instance.

  function Find();

  

Find the identity given menu item (named in ACaption).

  function GetEnumerator;

  

Gets an enumerator for the child menu Items in the class instance.

  procedure GetImageList();

  

Gets an image list with the available bitmaps for the menu item.

  function GetParentComponent; override;

  

Gets the menu for the Parent component when available.

  function GetParentMenu; virtual;

  

Gets the parent menu to which this menu item belongs.

  function GetMergedParentMenu; virtual;

  

Gets the parent menu to which this menu item belongs taking a merged menu into account.

  function GetIsRightToLeft; virtual;

  

Determines whether right-to-left display is enabled for the menu item.

  function HandleAllocated;

  

Indicates whether a Handle has been allocated for the menu item.

  function HasIcon; virtual;

  

True when a bitmap is configured and available for the menu item.

  function HasParent; override;

  

Indicates if the menu item has a parent menu item.

  procedure InitiateAction; virtual;

  

Updates the Action in the ActionLink for the menu item.

  procedure IntfDoSelect; virtual;

  

Performs actions needed when the menu item is selected using the LCL interface.

  function IndexOf();

  

Gets the ordinal position in Items for the specified menu item.

  function IndexOfCaption(); virtual;

  

Gets the ordinal position in Items for the menu item with the specified Caption.

  procedure InvalidateMergedItems;

  

Frees the MergedItems property for the menu item.

  function VisibleIndexOf();

  

Gets the ordinal position for the specified menu item in the list of visible menu items.

  procedure Add();

  

Adds item(s) to the menu item.

  procedure AddSeparator;

  

Adds a separator line to the child menu items.

  procedure Click; virtual;

  

Performs actions needed when the menu item is clicked.

  procedure Delete();

  

Deletes the child menu item at the specified position in Items.

  procedure HandleNeeded; virtual;

  

Ensures that a valid Handle exists for the menu item.

  procedure Insert();

  

Insert stores the specified menu item at the location indicated by Index.

  procedure RecreateHandle; virtual;

  

Re-creates the Handle for the menu item.

  procedure Remove();

  

Removes the specified menu item from its Parent.

  procedure UpdateImage();

  

Updates the image associated with the menu item.

  procedure UpdateImages();

  

Update the images for the menu item and its child items.

  function IsCheckItem; virtual;

  

Indicates if the menu item is configured as a check box or a radio button item.

  function IsLine;

  

True if the menu item is configured as a separator line.

  function IsInMenuBar; virtual;

  

True if the menu item has a TMainMenu instance as its Parent.

  procedure Clear;

  

Removes all child menu Items in the class instance.

  function HasBitmap;

  

Indicates whether a TBitmap instance has been assigned to the Bitmap property.

  function GetIconSize(); virtual;

  

Gets the size for the icon (glyph) when used on the menu item.

  procedure RemoveAllHandlersOfObject(); override;

  

Removes all handler routines for the specified object instance from the internal handler lists.

  procedure AddHandlerOnDestroy();

  

Adds an OnDestroy event handler to the handlers for the menu item.

  procedure RemoveHandlerOnDestroy();

  

Removes the specified OnDestroy event handler from the list of handlers for the menu item.

  procedure AddHandler();

  

Adds an event handler routine of the specified type to the menu item.

  procedure RemoveHandler();

  

Removes the event handler routine from the specified handler type.

  property Merged: TMenuItem; [r]

  

Menu item where the class instance and its children have been merged.

  property MergedWith: TMenuItem; [r]

  

Menu item where the current class instance was merged.

  property Count: Integer; [r]

  

Number of child menu items stored in the Items property.

  property Handle: HMENU; [rw]

  

Handle for the menu item allocated in the widgetset class.

  property Items []: TMenuItem; default; [r]

  

Provides indexed access to the child menu items for the current class instance.

  property MergedItems: TMergedMenuItems; [r]

  

Returns the visible and invisible child items taking the merged menu into account.

  property MenuIndex: Integer; [rw]

  

Ordinal position for the menu item in its Parent.

  property Menu: TMenu; [r]

  

Menu where the menu item is displayed.

  property Parent: TMenuItem; [r]

  

The parent menu item for the class instance.

  property MergedParent: TMenuItem; [r]

  

The parent menu item for the class instance taking the merged menu into account.

  property Command: Word; [r]

  

Numeric command for the menu item as assigned in the widgetset class.

  function MenuVisibleIndex;

  

MenuVisibleIndex - the index value of the visible menu.

  procedure WriteDebugReport();

  

Generates information about the menu item and its child Items for use in the debugger.

published

  property Action: TBasicAction; [rw]

  

Action is the default action associated with the menu item.

  property AutoCheck: Boolean; [rw]

  

Indicates whether a check mark state is read from the Action for the menu item (when assigned).

  property Caption: TTranslateString; [rws]

  

The caption text displayed for the menu item.

  property Checked: Boolean; [rws]

  

Indicates whether a check mark is displayed beside the menu item.

  property Default: Boolean; [rw]

  

Indicates if the menu item is the default selection.

  property Enabled: Boolean; [rws]

  

Indicates if the menu item can be selected and executed.

  property Bitmap: TBitmap; [rws]

  

Bitmap image (glyph) displayed for the menu item.

  property GroupIndex: Byte; [rw]

  

GroupIndex: the sequence number in a group of mutually exclusive RadioItem choices.

  property GlyphShowMode: TGlyphShowMode; [rw]

  

Indicates the display behavior for the glyph (or Bitmap) on the menu item.

  property HelpContext: THelpContext; [rws]

  

Index to the context-sensitive help string used for the menu item (context ID).

  property Hint: TTranslateString; [rws]

  

Contains hint text displayed for the menu item.

  property ImageIndex: TImageIndex; [rws]

  

Ordinal position in the list of images for the glyph displayed on the menu item.

  property RadioItem: Boolean; [rw]

  

Indicates if the menu item is displayed as a radio button.

  property RightJustify: Boolean; [rw]

  

Indicates if the menu item caption is displayed with right-justification.

  property ShortCut: TShortCut; [rws]

  

Accelerator key sequence to be used in selecting this menu item.

  property ShortCutKey2: TShortCut; [rw]

  

Secondary shortcut (accelerator) key for the menu item.

  property ShowAlwaysCheckable: Boolean; [rw]

  

ShowAlwaysCheckable - if True, Item is always shown as checkable.

  property SubMenuImages: TCustomImageList; [rw]

  

SubMenuImages indicates if images are shown for sub-menu items as well as the main item.

  property SubMenuImagesWidth: Integer; [rw]

  

Width for the bitmaps in the SubMenuImages property.

  property Visible: Boolean; [rws]

  

Indicates whether the menu item is visible (True) or hidden (False).

  property OnClick: TNotifyEvent; [rw]

  

Event handler signalled to perform the actions needed when the menu item is selected.

  property OnDrawItem: TMenuDrawItemEvent; [rw]

  

Event handler signalled to draw the menu item.

  property OnMeasureItem: TMenuMeasureItemEvent; [rw]

  

Event handler signalled to get the Width and Height for the menu item.

end;

Inheritance

TMenuItem

  

Represents a menu item displayed in a menu.

|

TLCLComponent

  

The base class for LCL components which have an associated widget.

|

TComponent,IUnknown,IInterfaceComponentReference

|

TPersistent,IFPObserved

|

TObject

Description

TMenuItem is a TLCLComponent descendant which represent a menu item displayed on a TMenu instance, or one of its derived classes like TMainMenu and TPopUpMenu.

TMenuItem has properties which define the display attributes for the menu item, and allows accelerator keys to be defined in the Caption for the item. Event handlers are also provided which perform actions needed when the menu item is measured, drawn, or clicked.

TMenuItem is the type added and maintained in the TMenu.Items property.

See also

TMenu.Items

  

Contains the menu items displayed on the menu.


Version 3.2 Generated 2024-02-25 Home