Margaret,
Let me see if understand correctly.
You have a menu bar that contains several menus. One of the menus is called "Comms". You want to populate this menu with various menu items whenever the user attempts to display this menu. However, you never want the menu to be empty, otherwise it becomes an immediate action menu (with the exclamation mark).
If that is correct, then you should use the dimmer callback to populate the menu. But make sure that there is always one item in there. It doesn't matter which, since the user will never see it. The point is only to prevent the exclamation mark from appearing; whenever the user operates the menu you can then replace this dummy entry with the actual list of comm ports.
Yes, it will be the case that this dimmer callback will be called not only when the user activates the Comms menu, but also any other menu in the menu bar. This doesn't affect the correctness program, as long as you *always* update your menu regardless of which menu the user selected. But you might have performance concerns, in case it takes time to do this. If that's the case I have a possible solution: there's an undocumented function (in other words, buyer beware...) that allows you to restrict dimmer events to a single menu. To use it, you'll have to add the following code to your program:
typedef void (__cdecl * MenuDimmerExCallbackPtr)(int menuBar, int menu, int menuItem, int panel, int event, void *callbackData, int eventData);
extern int InstallMenuDimmerCallbackEx (int menuBar, int menu, MenuDimmerExCallbackPtr dimmerFunction, void *callbackData);
Then, call InstallMenuDimmerCallbackEx instead of InstallMenuDimmerCallback to assign the callback, passing it the ID for the "Comms" menu.
- luis