General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › How to control where a new top level menu item lands
-
dcramer March 27, 2010 at 7:33 pm
How to control where a new top level menu item lands
March 27, 2010 at 7:33 pmParticipants 0Replies 1Last Activity 13 years agoHi there,
I'm adding a new top level menu from a script:[code]
var cmdBars = Application.CommandBars;
var menuBar = cmdBars.item(“Menu bar”);
var newTopMenu = menuBar.Controls.Add(5,,8); // Syntax error
newTopMenu.Caption = “&BroadBook”;
// add more items here.
[/code]How can I make it land after the Windows menu and before the Help menu? When I add 8 as the third param, I get a syntax error. I must not understand the reference docs:
“CommandBarControls_object.Add([intControlType], [variantCmdId], [variantBefore], [variantParam]);”
“variantBefore is a number that indicates the position of the new control in the collection; the new control is inserted before the control at this position. If this argument is omitted, the control is added at the end of the specified command bar. “
Thanks,
Daviddcramer March 27, 2010 at 7:42 pm
Reply to: How to control where a new top level menu item lands
March 27, 2010 at 7:42 pmNevermind. I found that if I add any number as the second param, then it works:
[code]
var newTopMenu = menuBar.Controls.Add(5,1,8);
[/code]The docs say “variantCmdId is an integer that specifies a built-in command to clone; if this argument is omitted, a blank custom control of the specified type is added to the command bar. “
It appears that you cannot omit this param. I'm not clear on what it does if I make the second param a 1 versus a 3.
Thanks,
David -
AuthorPosts
- You must be logged in to reply to this topic.