This doesn´t work.
Is there a way to do it with the ON_UPDATE_COMMAND_UI?
But I don´t know how I can get the state of the menu item entry and if I do it with this handler
everytime since I click the Menuheader without clicking the wanted item the function will be executed and I can´t find out how to catch only if i click my item.
Yes, using the ON_UPDATE_COMMAND_UI mechanism would be much better and easier.
Just do it in "reverse" oder comparing with your current algorithm:
set the variable m_bSetForeground to true if you expect the menu item to be checked and to false otherwise. Then in the ON_UPDATE_COMMAND_UI handler just check/uncheck menu item:
Code:
ON_UPDATE_COMMAND_UI(ID_CONFIGURE_SETTOFOREGROUNDININCOMINGCALL, OnUpdateForegroundIncommingCall)
END_MESSAGE_MAP()
.....
// somewhere set the flag to correspond the checked state
void MyClass::SomeMethod()
{
m_bSetForeground = true;
...
}
void MyClass::OnUpdateForegroundIncommingCall(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_bSetForeground ? 1 : 0);
}
Bookmarks