LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

swap menus using UIR built menus

I have a situation where I would like to change only one menu in a menubar depending on certain conditions.  I realize there's the EmptyMenu and NewMenu functions, but then I have to go and rebuild the entire menu each time.  These two menus I have built in my UIR, complete with icons, coloring, separators, callback functions, etc.  Fairly complicated to duplicate entirely in code.

 

The two look like this:

 

Edit Menu Bar all.png

 

Edit Menu Bar this.png

 

What's not shown above is that there are other adjacent menus in this menubar.  So I can't just remove the entire menubar.

 

Is there a simpler way of replacing the menus within a menu bar with a different menu from a UIR?

0 Kudos
Message 1 of 5
(4,803 Views)

I never tried myself but you possibly could

 

  1. save your UI to an ASCII file (Options / Save in Text Format)
  2. rearrange the ASCII file manually (rename all MenuBar001 to MenuBar003, then all MenuBar002 to MenuBar001, and finally all MenuBar003 to MenuBar001...)
  3. save the changed ASCII file
  4. read back the TUI file (Options / Load From Text Format).

Not very convenient but maybe better than your approach...

 

I thought having suggested some improved menu editor but couldn't find it... so maybe you go ahead...

0 Kudos
Message 2 of 5
(4,797 Views)

It's not clear to me whether you want to do this at design time or runt time. If at design time then you may follow the good suggestion from Wolfgang.

If at runtime, you could go a slightly different way: design a menu with all the functions you need to use in any condition, then install a menu dimmer callback to dim the items you cannot/must not use in the particular operating condition you are when the menu is shown. See this community thread for reference. I am using this way extensively and it's a very fast and robust concept schema.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 5
(4,786 Views)

Roberto, I was referring to a run-time solution.  And your dimming concept I am using now.  It works nicely.  But what I'm after is a slightly more efficient way of handling menus for the user. 

 

I like your reminder that I could simply make a single big menu which is a union of both menus that will show independently under the right conditions.  However, in my case, I would want to completely hide (for less visual clutter) the menu items that don't relate contextually.  I don't see that as an attribute type for menus, just dimming. The closest seems to be DiscardMenuItem, but this removes it from memory.

 

 

0 Kudos
Message 4 of 5
(4,763 Views)

I opted for the easier way out and used two separate menus with dimming.  I'm with you, Roberto.

0 Kudos
Message 5 of 5
(4,741 Views)