Delphi menu component TMainMenu use method detail _Delphi_ script home

Delphi menu component TMainMenu use method detailed

Updated: Nov 30, 2017 11:52:12 Author: Crazy Programming
This article mainly introduces the Delphi menu component TMainMenu in detail, has a certain reference value, interested partners can refer to it

This article shares the use of the menu component TMainMenud for your reference, the specific content is as follows

The menu component TMainMenu

To add a menu item, double-click TmenuMain and click Caption

Add a divider in the menu simply add "-" to add a divider

Cascade menu design

Click the right mouse button and select Create Submenu menu item from the pop-up menu

Single function design

To design the menu item, select the RadioItem property to True and the Checked property to True

Design of the check function

In the Design menu item, select the RadioItem property to False and the Checked property to True

Dynamic creation menu

Source code is as follows

procedure TForm1.Button1Click(Sender: TObject); var MainMenu: TMainMenu; MenuItem: TMenuItem; begin // Create a main menu. MainMenu:=TMainMenu.Create(self); Self.Menu:=MainMenu; // File menu creation MenuItem:= TMenuItem.Create(MainMenu); Caption:=' file '; MainMenu.Items.Add(MenuItem); // Create a new submenu.Create MenuItem:=TMenuItem. create (MainMenu); Caption:=' New '; MainMenu.Items[0].Add(MenuItem); // Submenu creation MenuItem:= TMenuItem.Create(MainMenu); Caption:=' Open '; MainMenu.Items[0].Items[0].Add(MenuItem); MenuItem:= TMenuItem.Create(MainMenu); Caption:=' Save '; MainMenu.Items[0].Items[0].Add(MenuItem); end; end.

Add ICONS to the main menu

To add an icon to the menu, first specify the icon for the menu using the TImagaList component, set the Images property in the menu to ImageList1, and then select the icon index to add. As shown in the picture:

The above is the whole content of this article, I hope to help you learn, but also hope that you support the script home.

Related article

Latest comments