NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically disabling menu items

I'm somewhat of a TestStand novice, so maybe there is something obvious I am missing.
 
I have taken the Visual C++ Full-Featured Operator Interface code and have modified it to allow a client application to send in "requests" to the Operator Interface to perform some basic functions like "run sequence", "suspend sequence", and of concern to this note "local/remote mode".  When the client application request "remote mode", I would like to disable most/all of the menu items and buttons on the GUI so that a user can watch the operator interface run through a sequence (started via the client application), but the operator would not be able to affect the running of the sequence nor start a new sequence nor do much of anything else.  Once the client application is done running the desired sequence, it would send a request to put the Operator Interface back into "local mode", and then all the menu options and buttons would be enabled again for the user standing at the Operator Interface console.
 
I can see that maybe one can manipulate the tools menu items using GetRunTimeToolMenuItems and then manipulating the RunTimeMenuItems returned, but I didn't dig deep enough into that to see if you actually disable the tools menu items.  In any case, I would like to disable more than just the tools menu items, so I'm hoping there is some other menu item access I can use.
 
Could I modify the RebuildMenuBar() function to take an argument that would basically not even paint the menu items when in "remote mode"?  Or is there something more straightforward?
 
Thanks for any suggestions.
0 Kudos
Message 1 of 3
(3,205 Views)
Barry,

The mMainMenu object in the TextExecDlg.cpp is of type CMenu.  The CMenu object allows you to Disable/Enable menu items by calling

mMainMenu.EnableMenuItem(itemID, enableFlag);

Where itemID refers to the ID number corresponding to the menu item and enableFlag is what effect on the MenuItem is desired.  For instance, if you would like to disable a menu item and have it grayed out you would use "MF_DISABLED | MF_GRAYED".  Check the help on the EnableMenuItem call for more information.

Please let me know if this provides you with the functionality you were desiring.

Thanks,

Tyler T
0 Kudos
Message 2 of 3
(3,180 Views)
Tyler, thanks for the suggestion.  Unfortunately, I could not get it to work.  I tried using existing resource IDs as well as creating my own using the menu items on the resources page of VC++.  I placed the call near the end of the RebuildMenuBar() method, trying both before and after the CleanupMenu() call.  I ran it in the debugger to make sure it was executing that call.
What I have done instead is to basically not execute any of the code in the various methods that build the top menu or the context menus when I am in certain modes.  The menu items still show up at the top, but clicking on them does nothing.  I think this is good enough for my purposes right now.  My guess why your suggestion is not working is that the TestStand mMenuBuilder object has complete control of that menu and blocks/ignores/overwrites/whatever any direct effect I try to provide "manually" in the CTestExecDlg class.  I initially had a similar "problem" when I was trying to modify the text on the execution buttons on the right side of the FileTab dialog (i.e. "Single Pass").  At least until I found you could pass flags into the mSequenceFileViewMgr->ConnectCommand() indicating that the mSequenceFileViewMgr should allow my overrides.  There are probably similar flags or function calls I can make on the mMenuBuilder object to allow me more control, but it's a minor issue at this point.
This tool gives you so much flexibility and power, but it can be a little daunting finding out how to effect changes when there are so many functions to wade through in the Help.
Thanks again for the suggestion.  I'm sure you'll see more of my postings the deeper I get into this.
0 Kudos
Message 3 of 3
(3,170 Views)