How do I programmatically dismiss a menu?

This question most commonly arises when wanting to "time-out" a menu. You can usurp the processing that Windows itself does: when Windows puts up a dialog or disables a window, it sends a WM_CANCELMODE message to tell the window to abandon all modal activities like menus. So you can achieve the same effect by sending this message to yourself.