How to do Menu Launch VIs

From LabVIEW Wiki

Jump to: navigation, search

Contents

Customizing LabVIEW Menus

LabVIEW provides a mechanism, which allows the user to open VIs and help files by selecting them from the Tools and Help pull-down menus. This is a very powerful feature for development tools creation, so I will describe how this works. When LabVIEW starts up it does several things, which include initializing the menus. This is a process where LabVIEW looks for files within specific directories for inclusion in the menus.

Menu Launch Folders


The .\wizard, .\project, and .\help folders are intrinsically related to the "File", "Tools", and "Help" menus, respectively. When you install a LabVIEW add-on, you will notice that new menu items are usually added to these two menus. This was achieved by adding files to the .\project and .\help folders. Through a little experimentation the nature of this process has been determined to be the following:

Technical details

First, LabVIEW looks in the .\wizard, .\project, and .\help folders for standalone VIs and top-level VIs within LLBs. In the .\help folder, it also looks for .hlp and .chm compiled help files. These files are then opened when selected from the menu. LabVIEW will look recursively through all subfolders and LLBs looking for these files of interest. However, the search will ignore any VIs, folders, or LLBs whose name begins with an underscore ("_") character. When the search finds a file of interest it will create a menu item at a location, which reflects where it found it in the directory structure inside the project or help folder. For Example, if it finds the file .\project\Goop Tools\Rename Goop Class.vi, it will create the menu item Tools/GOOP Tools/Rename GOOP Class.

Menu Naming method

Here is where a twist is thrown into the naming rules. You can override the names of the VIs, .chm and .hlp files, folders and LLBs so that they are named differently in the menu structure from their names on disk. For VIs, LabVIEW will use the "Window Title" as the menu name (this is also the VI Server VI:Front Panel Window:Title property). But, by placing a text file with the identical root name (RootName.vi, RootName.txt) in the same location as the folder or file, you can specify the name LabVIEW should use in the menus. The name you wish to use in the menu should be placed in the text file. For example, if you have a VI called MyBuggyCode.vi, you can make the menu item show up as Elegant Solution by creating a text file called MyBuggyCode.txt that contains the contents "Elegant Solution" and placing it in the same directory as MyBuggyCode.vi.

Note that this override method works for LLBs, folders, .hlp, and .chm files, but for .hlp and .chm files you must also add the characters ".hlp" or ".chm" after the menu item name in the overriding text file. The file MyCHM.chm should have an override text file called MyCHM.txt that contains the contents "All The Help You Need.chm" This will cause its menu name to be "All The Help You Need".

Autorun

How does the developer use this feature, whereby they can open VIs and help files from the menu? VIs placed in the Tools menu (.\project folder) should always be set to "Run When Opened". This will cause them to look and feel like a functional dialog or tool once they are opened after being selected from the menu.

Notes

The .\wizard (Files) VIs don't show up in Project windows.

Get calling VI

Private Feature Exposed
There is a private VI server method called Application:Menu Launch VI may be found exposed on the diagram of the "Web Publishing Tool" (.\project\webdoc.llb\_Web Document Tool.vi) this property returns the last VI to call a "Tools" menu VI (it doesn't work for "Help" menu), but returns it only once then returns a null string until another "Tools" menu VI is selected from the menu. Use this feature to create a tool that operates on the VI that the user launched it from, like "Check into Source Code Control", or something similar. Unfortunately this does not work for the File (.\wizard) or Help (.\help) menus.
Personal tools
Namespaces
Variants
Actions
Navigation
interaction
Toolbox