Customizing Menus Programmatically

Complete the following steps to customize a menu programmatically.

  1. Select Edit»Run-Time Menu to display the Menu Editor dialog box.
  2. Select Custom from the Menu Type pull-down menu. The question marks in the Hierarchy listbox indicate that you are creating a new item that does not have a name yet.
  3. Select File»Save and name the custom menu. You can save the menu file wherever you choose.
  4. Close the Menu Editor dialog box.
  5. Add the Current VI's Menubar function to the block diagram.

     Add  Find
  6. Add the Insert Menu Items function to the block diagram.

     Add  Find
  7. Wire the Current VI's Menubar function to the menu reference input of the Insert Menu Items function.
  8. Right-click the item names input of the Insert Menu Items function and select Create»Constant from the shortcut menu. An array constant appears.
  9. Type File in the 0 slot and Edit in the 1 slot of the array.
  10. Right-click the item tags input of the Insert Menu Items function and select Create»Constant from the shortcut menu. An array constant appears.
  11. Again, type File in the 0 slot and Edit in the 1 slot of the array. Menu item tags can have the same name as menu item names.
  12. Add a While Loop to the block diagram so the While Loop encloses the menu functions.

     Add  Find
  13. Add the Wait (ms) function inside the While Loop to delay execution.

     Add  Find
Note  You must wire a value to the milliseconds to wait input of the Wait (ms) function for the VI to run.
  1. Switch to the front panel window and click the Run Continuously button. A File and Edit menu appear in the front panel window. However, there are no submenu items.

Adding Submenu Items to Existing File and Edit Menus

Complete the following steps to add submenu items to existing File and Edit menus.

  1. Add another Insert Menu Items function to the block diagram to the right of the first Insert Menu Items function.

     Add  Find
  2. Wire the menu reference out and error out output of the first Insert Menu Items function into the menu reference and error in input of the second Insert Menu Items function.
  3. Wire all error in and error out terminals on the block diagram.
  4. Right-click the menu tag input of the second Insert Menu Items function and select Create»Constant from the shortcut menu. A string constant appears.
  5. Type File in the string to add items in the File menu you created in step 9.
  6. On the second Insert Menu Items function, right-click the item names input and select Create»Constant from the shortcut menu. An array constant appears.
  7. Type Menu1 in the 0 slot and Menu2 in the 1 slot. Repeat this step for the item tags input.
  8. Switch to the front panel and click the Run Continuously button. The front panel window includes a File menu and an Edit menu with Menu1 and Menu2 as subitems in the File menu.
  9. Use a Case Structure to execute the menu items.
Note  You also can add default LabVIEW menu items by providing the application item tags as inputs to the Insert Menu Item function.

Refer to the labview\examples\Dialog and User Interface\Menu\Customizing the Menubar\Customizing the Menubar.lvproj for examples of customizing menus programmatically.

 Open examples  Find related examples