how to set check on menu item mfc c++ i try this but, always unchecked menu item.
CString tcBuff;
CMenu popMenu;
popMenu.LoadMenu(nMenuID);
if (text.Compare(defaultconfig) == 0)
{
tcBuff.LoadStringW(IDC_DEFAULTREMOVE);
popMenu.ModifyMenuW(ID_CONFIGURATION_DEFAULT,0,ID_CONFIGURATION_DEFAULT,tcBuff);
popMenu.CheckMenuItem(IDC_DEFAULTREMOVE, MF_CHECKED || MF_BYCOMMAND);
}
thanks for help.
You want the
|operator, not the||operator.You want to combine the
MF_CHECKEDandMF_BYCOMMANDbit flags, which you do with a bitwise OR operation. That requires the|operator.Change your code to look like this:
The
||operator is the logical OR operator. It actually gives you this:Which is equivalent to
MF_UNCHECKED.