Adding a macro to a standard System Architect menu
The main SA2001.Application method to support the adding of macro items is:
InsertMacroItemInMenu(MacroName as String, MacroItemCaption as String, InMenuTitleCaption as String, [BeforeMenuItemCaption as string]) as long
This function adds the MacroName (which comprises: "<Project>.<Module>.<Subroutine>") using the caption MacroItemCaption to the SA/User menu titled InMenuTitleCaption, before the menu item titled BeforeMenuItemCaption. If no Before item is specified then the item is added to the end of the menu. If the before item is #TOP# then the item inserted at the top of the menu.
The function returns 0 if successful, otherwise non-zero.
In other words:
Set App = New SA2001.Application x = App.InsertMacroItemInMenu("MyProject.MyModule.MySub", "&Test Item", "&Tools","Ma&cros")
This inserts the item Test Item in the Tools menu, before the Macros popup item. When the item is clicked on, the subroutine MySub is executed in the module MyModule in the project MyProject.
For this to succeed the subroutine specified must already exist. Also, the captions must be specified exactly as in the menu.
For example, Tools is represented as the string: &Tools
An ampersand implies an underscore under the following letter. This is case sensitive.
The subroutine name should not have () following it.
The adding of BMPs to menu items is done by the AssignBMPtoMacroItem method.
AssignBMPtoMacroItem(MacroName as String, BMPFileName as String) as long
This function returns zero if successful, or non-zero otherwise.
This should be done prior to adding the macro item to the menu, but need only be done one time.
For example:
Set App = New SA2001.Application x = App.AssignBMPtoMacroItem("MyProject.MyModule.MySub", "C:\Piccy.BMP") x = App.InsertMacroItemInMenu("MyProject.MyModule.MySub", "&Test Item", "&Tools","Ma&cros")
This adds the Piccy.bmp to the MySub macro, then add it to the menus as in the previous example.
The customize menus (right‑click on menus) command now includes the Piccy.bmp and the caption &Test Item, if you wanted to put the menu item anywhere else in your menus.