CMenu::RemoveMenu is failing
Posted on 2003-02-27
I am using RemoveMenu() to remove ALL menu items in my sub menus, however it does not delete ALL the items. It fails to remove a couple of items.
I cannot figure out why it is not deleting all the items
I have tried using GetLastError() however this only returns 0.
Any help would be much appreciated !
void myModule::RemoveSubMenuItems( CMenu* &pSubMenu)
// Remove All menu items from the sub menu.
int count = pSubMenu->GetMenuItemCount();
for (int i = 0; i < count; i++)
if (!pSubMenu->RemoveMenu(i, MF_BYPOSITION))
DWORD dw = GetLastError();
sprintf(szBuf, "FAILED to RemoveMenu item: GetLastError returned %u\n", dw);