Copy a menu item from a TMainMenu to an empty popup menu (Views: 28)
Problem/Question/Abstract: 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: procedure TForm1.PopupMenu1Popup(Sender: TObject); var I: Integer; MenuItem: TMenuItem; begin TPopupMenu(Sender).Items.Clear; {Copy menu items from first mainmenu (File1)} for I := 0 to File1.Count - 1 do begin with File1.Items[I] do MenuItem := NewItem(Caption, ShortCut, Checked, Enabled, OnClick, HelpContext, Name); TPopupMenu(Sender).Items.Add(MenuItem); end; end; |