Author: Pieter Zijlstra
How to copy a menu item from a TMainMenu to an empty popup menu
Answer:
This will only copy the first level of menu items:
1 procedure TForm1.PopupMenu1Popup(Sender: TObject);
2 var3 I: Integer;
4 MenuItem: TMenuItem;
5 begin6 TPopupMenu(Sender).Items.Clear;
7 {Copy menu items from first mainmenu (File1)}8 for I := 0 to File1.Count - 1 do9 begin10 with File1.Items[I] do11 MenuItem := NewItem(Caption, ShortCut, Checked, Enabled, OnClick, HelpContext,
12 Name);
13 TPopupMenu(Sender).Items.Add(MenuItem);
14 end;
15 end;