loadSubMenu

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

loadSubMenu

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:07 pm

by John Munro >> Tue, 3 Apr 2007 19:18:53 GMT

Does anyone have experience with loadSubMenu? I can't get it to do what I want.

What I want to do is create groups of a menu with two submenus at runtime.

So in the painter I have these menus:

Menu
SubMenuA
SubMenuB

Then at runtime I want to be able to make

Menu_1
SubMenuA_1
SubMenuB_1
Menu_2
SubMenuA_2
SubMenuB_2
.....

I can't find any examples of using loadSubMenu and I've been over its entry in the help file more times than I care to think

Thanks,

John Munro

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: loadSubMenu

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


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests