This topic seems to have cropped up regularly over a decade or more. I have ploughed through the exchanges in all the forums, yet I still cannot make it work. The following is a tiny Code::Blocks program, written to isolate the
problem:
// main.cpp
... minimal code down to the Switch instruction of case WM_COMMAND, and then ...
case ID_DISABLE:
EnableMenuItem((HMENU)IDR_MYMENU,ID_MESSAGE,MF_GRAYED);
break;
case ID_ENABLE is similar to case ID_DISABLE above, and neither works. case ID_MESSAGE and case ID_EXIT both works as expected.
I have tinkered with EnableMenuItem(), as various posts have suggested, but without success. Can anybody help?
An ID is not an HMENU. Forcibly casting to one won't work (don't cast around compiler errors! The compiler is telling you something is wrong... casting around it just tells the compiler to shut up without actually solving the problem)
Thanks L B, but MF_DISABLED instead of MF_GRAYED stop the window appearing. (I am sure I remember reading that GRAYED is preferred now. Maybe that's wrong.)
Peter
Ah, I don't know, all I know is that it was either MF_GRAYED or MF_DISABLED that had a comment in the windows headers saying to use the other one. I remember having an issue similar to this but I can't find where the code is.