Procedure TForm1.Button1Click (Sender: TObject); var MainMenu: exposed by the TMainMenu; the MenuItem: TMenuItem; the begin // Create the main menu object, and set the main window menu objects MainMenu MainMenu: = exposed by the TMainMenu. the Create (Self); Self.Menu: = MainMenu; // Create MainMenu first level menu of the main menu objects MainMenu.Items.Add the MenuItem: = TMenuItem. the Create (MainMenu); MenuItem.Caption: = ' a menu ' ; MainMenu.Items.Add (the MenuItem); // Create the main menu MainMenu second submenu subject [0] .Add MainMenu.Items = TMenuItem: the MenuItem. the Create (MainMenu); MenuItem.Caption: =' Secondary menu ' ; MainMenu.Items [ 0 ] .Add (the MenuItem); // Create the main menu MainMenu third level sub-menu objects MainMenu.Items [0] .Items [0] .Add the MenuItem: = TMenuItem. The Create (a MainMenu); MenuItem.Caption: = ' third level ' ; MainMenu.Items [ 0 ] .Items [ 0 ] .Add (the MenuItem); // with Items [0] ... in this form, can create four , up to five N-level menus can be the MenuItem: = TMenuItem. the Create (a MainMenu); MenuItem.Caption: = ' four menu ' ; MainMenu.Items [ 0 ] .Items [ 0 ] .Items [ 0] .Add (MenuItem); End ; // Popup Event Procedure TForm1.Button1Click (Sender: TObject); var PM: TPopupMenu; mi: TMenuItem; the begin PM: . = TPopupMenu the Create (Self); mi: = TMenuItem. The Create (Self); mi.Caption: = ' New (& N) ' ; pm.Items.Add (mi The); mi The: . = TMenuItem the Create (Self); mi.Caption: = ' open (O &) ' ; pm.Items.Add(mi); mi := TMenuItem.Create(self); mi.Caption := '-'; pm.Items.Add(mi); mi := TMenuItem.Create(self); mi.Caption := '退出(&X)'; pm.Items.Add(mi); mi.OnClick := miClick; Button1.PopupMenu := pm; end; // 在类里定义 procedure TForm1.miClick(Sender: TObject); the begin the Close; End ; Add rehabilitation options in the system menu: the Append (the GetSystemMenu (handle, to false), MF_SEPARATOR, 0 , '' ); the Append (the GetSystemMenu (handle, to false), MF_STRING, 200 is , ' the About (& A) ' ); WM_SYSCOMMAND message handler Procedure SystemMenuCommand ( var Msg: TWMMENUSELECT); message WM_SYSCOMMAND; Procedure TForm1.SystemMenuCommand ( var Msg: TWMMENUSELECT); the begin IF Msg.IDItem = 200 is the then Form2: . TForm2 = the Create (the Application); Form2.Show; Form2.Update; end; inherited; end;