I'm trying to merge two main menus together, but am having problems getting the right result with sub-items. I'm using the GroupIndex property on my MenuItems to control the merging/insertion.
Menu1 (with groupindices) is like this
Menu2 is like this
And I'm doing
Menu1.Merge(Menu2);
I want the combined menu to have a new top menu "Widgets"and a new "Clear" command in the Edit menu. "Widgets" is working fine, but the Edit Menu has lost cut and paste, which wasn't what I wanted.
How can I stop the Cut and Paste commands from disappearing?
The menu merge feature in Delphi works a bit differently than what you'd expect: it's non-recursive (unfortunately!). That means that when you call Menu1.Merge, Menu1's "Edit" menu gets replaced by Menu2's.
You have two options:
I had the same problem a while ago (see this SO question):
What I eventually ended up with, is using the Toolbar2000 package for all my menus and toolbars. You can then download a very nice piece of code, called TB2Merge, which does exactly what you want.
You could also base any custom-written menu merge code on TB2Merge, I guess...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With