The cleverest way I know to accomplish what you need is to use InstallMenuDimmerCallback () function in your program. This
callback is executed every time the user clicks on the menu bar but before the menu bar is displayed: this way you dim or enable some menu item depending on particular conditions you find in this moment.
An example on how to use this function: suppose you have a menu with items that refers to a test (setup - start - stop - save test data) and a global variable that holds the "state" of the equipment; in the callback you can dim setup, start and save data items if the test is executing, leaving only the stop option active, or enable save test data only at test completion...