How can Enable and Disable menu item?
Hi all,
How can Enable and Disable Menu item in SDI type application of MFC-VC++2005.There is Enable and disable propery is present in Menu Properties but i dont want to use it because it is manully enable and disable menu item.
i want to enable and disable requried menu item with using of function.
Please help me for this how can i do this.
Thanks in advance.
Re: How can Enable and Disable menu item?
Re: How can Enable and Disable menu item?
Since it's SDI, the preferred way of doing this is with the ON_COMMAND and ON_UPDATE_COMMAND_UI macros.
Look in the MESSAGE_MAP of your view. You should see some common handlers already:
Code:
BEGIN_MESSAGE_MAP(CMyView, CScrollView)
//...
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
END_MESSAGE_MAP()
See:
http://msdn.microsoft.com/en-us/libr...b7(VS.80).aspx
Re: How can Enable and Disable menu item?
And if you are not using MFC, take a look at WM_INITPOPUPMENU to get the menu just before it is shown, then use EnableMenuItem() to Enable or Disable it.
-Erik