Menu Component Tmainmenu
Create a menu double-click Tmenumain, and you can add a menu item by clicking Caption
Add a split line to the menu by simply adding "-" to add a split line
Cascading menu Design
Click the right mouse button pop-up menu to Choose Create Submenu menu item
Single-selection function design
To select the Radioitem property in the menu item that is designed to be true,checked property is True
The design of the check function
Select the Radioitem property in the Design menu item for the False,checked property to True
Creating menus dynamically
The source code is as follows
procedure Tform1.button1click (sender:tobject);varMainmenu:tmainmenu; Menuitem:tmenuitem;begin
Main Menu Create MainMenu:=tmainmenu.create (self); Self.menu:=MainMenu; File menu Create MenuItem:=tmenuitem.create (MainMenu); Menuitem.caption:='file'; MAINMENU.ITEMS.ADD (MenuItem); Create a new submenu MenuItem:=tmenuitem.create (MainMenu); Menuitem.caption:='New'; mainmenu.items[0]. ADD (MenuItem); submenu in submenu Create MenuItem:=tmenuitem.create (MainMenu); Menuitem.caption:='Open'; mainmenu.items[0]. items[0]. ADD (MenuItem); MenuItem:=tmenuitem.create (MainMenu); Menuitem.caption:='Save'; mainmenu.items[0]. items[0]. ADD (MenuItem); end;end.
Add an icon to the main menu
To add an icon to the menu, first use the Timagalist component to assign a good icon to the menu, set the Images property in the menu to ImageList1, and then select the icon index to add. :
Delphi's menu component (Tmainmenu)