Link to home
Start Free TrialLog in
Avatar of Michael Sterling
Michael SterlingFlag for United States of America

asked on

attach a main menu to a unit

i've created a customized unit (a TForm Class) and have created a TMainMenu component in code. I need to make sure that when forms of this class are created that the TMainMenu item gets assigned and shows on the form,..how do i do this? Ultimately what i'm trying to do is "transfer" an existing main menu from a form that gets docked inside of another form, so that the receiving form gets the menu, since i lose the original main menu when the dock is complete.
Avatar of Michael Sterling
Michael Sterling
Flag of United States of America image

ASKER

as a follow up, maybe another question i can/should ask is,..in a DockDrop or DockOver event you have "Source" as part of your parameter list how do i grab the Source's MainMenu item (presumming that i know there will be one ahead of time) and assing it to the main menu item of the form i'm docking to?
Avatar of Geert G
a menu has a procedure called merge
to merge the menu of the docked form to the main window:

MainForm.Menu.Merge(DockedForm.Menu);

for the merge to work correctly you need to set the GroupIndex property of each main menu item
Like in the MainMenu set File GroupIndex to 1, Help to 100
For a dockedform you could set GroupIndex to 90
They get ordered by this groupindex in the combined menu
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial