Registriert seit: 16. Feb 2008
Ort: Baden-Württemberg
2.332 Beiträge
Delphi 2007 Professional
|
AW: Ein MenüItem in mehrere PopUp Menüs adden
15. Apr 2013, 21:26
Einfach kopieren...
Delphi-Quellcode:
procedure CloneMenuItem(source, dest : TMenuItem);
begin
dest.Action := source.Action;
dest.Caption := source.Caption;
dest.ShortCut := source.ShortCut;
dest.Checked := source.Checked;
dest.Enabled := source.Enabled;
dest.Visible := source.Visible;
dest.OnClick := source.OnClick;
dest.HelpContext := source.HelpContext;
dest.Hint := source.Hint;
dest.RadioItem := source.RadioItem;
end;
procedure CopyMenuItems(source, dest : TMenuItem);
var
i : Integer;
mi : TMenuItem;
begin
Assert(Assigned(source), 'no source menu item');
Assert(Assigned(dest), 'no destination menu item');
dest.Clear;
for i :=0 to source.Count-1 do
begin
mi := TMenuItem.Create(dest);
CloneMenuItem(source.Items[i], mi);
dest.Add(mi);
if source.Items[i].Count > 0 then
CopyMenuItems(source.Items[i], mi); // rekursiver Aufruf ;-)
end;
end;
CopyMenuItems(PopupMenu1.Items, PopupMenu2.Items);
|
|
Zitat
|