Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:07 pm
by Michael J >> Wed, 4 Apr 2007 2:34:11 GMT
If you want a copy routine that will copy any menu structure its a little more complicated, but for copying a known menu structure its a simple process (Although confusingly the concept is slightly different than the concept behind using loadControl).
The variable names below roughly correspond to your example variable names. This will create an equivalent menu structure.
vars
vNewMenu_1 : MenuItem; // First copy of the main Menu Item vSubMenuA_1 : MenuItem; // First copy of sub menu A
vSubMenuB_1 : MenuItem; // First copy of sub menu A
begin
vNewMenu_1 := mnuMenu.loadMenu( 1 );
vSubMenuA_1 := vNewMenu_1.loadSubMenu( 2 ); vSubMenuA_1.setEventMapping( 'click' , 'mnuSubMenuA_click' ) ; vSubMenuA_1.caption := mnuSubMenuA.caption;
vSubMenuB_1 := vNewMenu_1.loadSubMenu( 3 ); vSubMenuB_1.setEventMapping( 'click' , 'mnuSubMenuB_click' ); vSubMenuB_1.caption := mnuSubMenuB.caption;
end;
Unfortunately I cant see a way of copying submenu items from one parent to the next. The next best thing is to use the event mapping. The control passed into the click event in this case will be the clone with its own unique index.
Regards,
Michael Jones