The old question, is for menu on dialog, to change the menu caption which no id How do I dynamic change MENU text which without ID the code is
////////////////////////////////////////////////////////
//CMenu* pMenu = CMenu::FromHandle(GetSkinMenu(m_pMainWnd->m_hWnd))->GetSubMenu(1);
HMENU hMenu;
hMenu=LoadMenu(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_MENU_S8521));
//CMenu* pMenu = CMenu::FromHandle(hMenu);
CMenu* pMenu = GetMenu();
int i, nCou = pMenu->GetMenuItemCount();
UINT uID;
CString strMenu;
for (i = 0; i < nCou; i++)
{
uID = pMenu->GetMenuItemID(i);
if (uID == 0) // separator
{
//TRACE(_T("----------------------\n"));
continue;
}
//pMenu->GetMenuString(i, ss, MF_BYPOSITION);
if (uID == (UINT)-1)
{
//TRACE(_T("Popup '%s' "), ss);
if(i == 0)
{
strMenu = theApp.mLang.structMenuLang.strMenuFile;
}
if(i == 1)
{
strMenu = theApp.mLang.structMenuLang.strMenuSet;
}
if(i == 2)
{
strMenu = theApp.mLang.structMenuLang.strMenuLanguage;
}
if(i == 3)
{
strMenu = theApp.mLang.structMenuLang.strMenuHelp;
}
pMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING|MF_ENABLED, 0, strMenu);
//TRACE(_T("modified to '%s' "), ss);
}
//else
// TRACE(_T("Item '%s', ID=%d "), ss, uID);
//TRACE(_T("\n"));
}
//Invalidate(true);
//UpdateWindow();
this->SetMenu(pMenu);
Now I want to change the MID menu caption which also no id,
the keyword code is
this->SetMenu(pMenu);
then the menu will reflash. My question is On MDI Menu, how do I reflash the menu caption , In out command window i find the TRACE message is right, but the UI no change.
ok, I get method to solve it using
CMenu menu;
menu.LoadMenu(IDR_MENU_MAIN);
AfxGetMainWnd()->SetMenu(pMenu);
AfxGetMainWnd()->DrawMenuBar();
pMenu->Detach();