» Creating a Development Tool » Integrating into the LabVIEW Menus
Menu integration is needed for many LabVIEW tools. Menu items give the end-user quick and easy access to an add-on's functionality. This document will illustrate how to place items into the menus and how to customize their appearance.
Custom menu items may be placed in the LabVIEW File, Tools, and Help menus. Custom menu items can be created by placing folders and VIs in select LabVIEW sub-folders. The following table lists menu and corresponding folder location for custom menus, where labview is the installation directory of LabVIEW, for example C:\Program Files\National Instruments\LabVIEW 2009.
Note: Custom menu items in the wizard directory will be displayed in the "File" menu for VIs, but not for projects.
LabVIEW creates menus at launch based on the contents of these three folders. VIs in these folders will appear as a menu item, and will open when selected. Top-Level VIs in LLBs are treated the same as VIs. Sub-folders will appear as sub-menu items.
VIs will open when selected from the menu, but will not automatically run. If a VI should run when selected, set the VI to “Run when opened” in the Execution page of VI Properties.
The following image is an example of a custom menu item, “Custom Menu” created in LabVIEW. Notice that “Custom Menu” contains two items and one sub-menu. The folder structure is also shown. Notice that this folder is located in labview\project and contains two VIs and one sub-folder. The VIs are displayed in the menu as items, and the sub-folder is displayed as a sub-menu.
All VIs, LLBs, and folders with filenames beginning with an underscore ("_") will not be included in the menu. Also, folders that do not contain a VI or LLB anywhere in their hierarchy will not be included, as they would have no sub-items.
The VI Window Title (File » VI Properties » Window Appearance » Window title) is the used for the item name. By default, this is the name of the VI, with the “.vi” extension removed. In the above example, A. First VI.vi is listed in the menu as “A. First VI...”. You may also customize the menu item name by changing the Window title. All VI names in the menu are terminated with an ellipsis (“...”), indicating to the end-user that an action will take place.
Folders are given the same name in the menus as on disk. In the above example, the folder “Custom Menu” contains a sub-folder “B. Sub Menu”; these are listed in the Tools menu by their folder names.
Menu items, both folders and VIs, are listed alphabetically by default. This layout can be customized with a ASCII text (.txt) file. By creating a text file in a sub-folder, you can change the order of the items and insert separators.
The text file must have the same name as its containing folder.
Folders and VIs should be listed by filename in the desired order in the text file.
Separators can be denoted by a dash (“-”).
Each entry - whether a VI, folder, or separator – must occupy its own line in the text file.
In the above examples, a text file Custom Menu.txt could be placed in the “Custom Menu” folder to modify the layout. Below is an example of possible Custom Menu.txt contents.
B. Sub Menu
C. Last VI.vi
A. First VI.vi
This text file would modify the menu item order and insert a separator, as seen below.
Any items that are not listed in the text file will be added after the text file's contents. In the example above, if the text file had not listed “A. First VI.vi”, the menu would look identical, as “A. First VI” would be listed after the other three lines.
It many situations, it is useful for a menu item to obtain information about the VI that was open when the menu was selected. The example Get VI Information from a Menu Item illustrates this process.