Reply to: Creating a custom toolbar?February 15, 2013 at 9:32 pm
The duplicate toolbar item showing in the list is a known issue that we haven't bothered to fix due to it not affecting users (and because as always, there are more important things to fix that actually do affect them). Since the entire CommandBar system is being rewritten for 8.0 it might even go away without us never knowing what caused it. If it persists then we'll log it under the new CommandBar system. In our testing of 6.0 and 7.0 it doesn't always happen, but when it does it has no effect on anything and will go away eventually just as you say.
Here are the basic rules in plain English for creating custom toolbars, which my script and the other examples included with XMetaL demonstrate.
- Toolbar or menu modifications can only be made in On_Default_CommandBars_Complete or in On_Local_CommandBars_Complete.
- Don't recreate a custom toolbar every time On_Default_CommandBars_Complete runs. If you do, eventually a limit will be reached and subsequent runs of your script will fail to do what you expect.
- Don't recreate a custom toolbar button or menu item every time On_Default_CommandBars_Complete runs. If you do, eventually a limit will be reached and subsequent runs of your script will fail to do what you expect.
- To undo the effects of On_Default_CommandBars_Complete, remove the startup macros responsible and restart XMetaL with the Ctrl-key held down to reset the workspace.
The 2nd and 3rd limitations exist because there is a limit on the number of unique ids available for toolbars and toolbar buttons in MFC (something that is completely hidden from you and that you have no control over).