旧的问题,是对话菜单,更改没有id的菜单标题 How do I dynamic change MENU text which without ID 代码是
////////////////////////////////////////////////////////
//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);
现在我想更改MID菜单标题,也没有id,
关键字代码是
this->SetMenu(pMenu);
然后菜单将重新刷新。我的问题是在MDI菜单上,如何重新刷新菜单标题 ,在out命令窗口中,我发现TRACE消息是正确的,但UI没有变化。
答案 0 :(得分:0)
好的,我得到了使用
解决它的方法CMenu menu;
menu.LoadMenu(IDR_MENU_MAIN);
AfxGetMainWnd()->SetMenu(pMenu);
AfxGetMainWnd()->DrawMenuBar();
pMenu->Detach();