No, this in not correct. You need to go to the Class View, then go to the Events tab and add an ON_UPDATE_COMMAND_UI
handler.
Inside the implementation, you call pCmdUI->Enable()
and/or pCmdUI->SetCheck()
or pCmdUI->SetRadio()
, depending on the functionality you want the UI items to have. What is so much great with this mechanism is that you don't need to call some sort of say, UpdateUIItems()
function after every operation that may affect the enable/check/radio state of the UI items, instead the framework calls the handlers, while your app is entering the idle state. Of course, the code evaluating the above conditions must be as fast as possible. Do not perform lengthy operations in there. Try playing a short sound in such a handler (eg Beep(1000,25)
) to see how frequently these are called. Data must be created, read or modified, in the ON_COMMAND
handlers. In the ON_UPDATE_COMMAND_UI
handler you must just tell the framework the state of the UI items.
Check the UI Update Mechanism. Also, my older posts here and here.