Danny01
asked on
CMenu::RemoveMenu is failing
Hi,
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 !
Thanks,
Danny
void myModule::RemoveSubMenuIte ms( 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))
{
CHAR szBuf[80];
DWORD dw = GetLastError();
sprintf(szBuf, "FAILED to RemoveMenu item: GetLastError returned %u\n", dw);
AfxMessageBox(szBuf);
}
}
}
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 !
Thanks,
Danny
void myModule::RemoveSubMenuIte
{
// 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))
{
CHAR szBuf[80];
DWORD dw = GetLastError();
sprintf(szBuf, "FAILED to RemoveMenu item: GetLastError returned %u\n", dw);
AfxMessageBox(szBuf);
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER