Re: How to disable a menu
Wow~, Thanks.
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> ????
news:%23XOeGEAWIHA.5716@TK2MSFTNGP05.phx.gbl...
"&#>" <pop520boy@163.com> wrote in message
news:%236209u$VIHA.6044@TK2MSFTNGP05.phx.gbl...
Hello
I am doing a VC++ 6.0 project with menus. And I would like to disable
some menu occasionly. For Example:
/**
void CView:: OnAdd()
{
m_iCount++;
if (m_iCount == MAX_NUMBER)
// Here I wanna disable
// this IDM_ADD menu.
}
**/
Certainly, I will enble this menu some other place.
Thanks & Best Regards.
pop520boy@163.com
You can't do it that way. Instead, MFC queries all the UPDATE_COMMAND_UI
handlers when the menu is about to be shown. Use class wizard to add a
message handler for UPDATE_COMMAND_UI for menu item IDM_ADD. In the
message handler do this:
pCmdUI->Enable(m_iCount < MAX_NUMBER);
Use any bool variable or expression you like to enable/disable the menu
item.
--
Scott McPhillips [VC++ MVP]