I have a Menu with all sorts of Menu items, as you normally would. Every MenuItem (button) has a caption and I'd like to change that caption at runtime. On a normal button that isn't really a problem, I just call GetDlgItem(ID)->SetWindowText(CString);
However I can't do that on the menu items since I can't assign ID's to any of them. The ID field in the Properties editor actually says "ID can not be edited".
So how do I change the menu items text at runtime?
EDIT: I have tried using the CMenu::ModifyMenu however I have been unsuccessful. I don't know how to specify the button (element) to change. Also, I have doubts in the correctness of the way I pass the CString as an argument.
This is my (failed) attempt:
CString str = "Foo";
CMenu * pMenu = m_wndToolBar.GetMenu();
pMenu->ModifyMenu(1, MF_BYPOSITION | MF_STRING, 0 /*Don't know what to pass as nIDNewItem */, str);
This (the call to the ModifyMenu method) throws a debug assertion error. Please not that I don't know what nIDNewItem.