There is an ON_UPDATE_COMMAND_UI mechanism in MFC to enable/disable menu items as well as toolbar buttons