EDN Admin
Well-known member
Hi
How do i change menu item text at Runtime in MFC Dialog based application.
///my code <font size=2>
CMenu m_Menu,*p_subMenu;
CString strMenuString;
CString strTMP;
m_Menu.LoadMenu(IDR_MY_MENU);
p_subMenu = m_Menu.GetSubMenu(0);
p_subMenu->GetMenuString(ID_ENABLE,strMenuString,MF_BYCOMMAND);
strTMP.LoadString(IDS_MENU_DISABLE);
</font><font color="#0000ff" size=2>if</font><font size=2>(strMenuString.CompareNoCase(strTMP)==0)
{
strMenuString.LoadString(IDS_MENU_ENABLE);
}
</font><font color="#0000ff" size=2>else
</font><font size=2>{
strMenuString.LoadString(IDS_MENU_DISABLE);
}
BOOL bChanged = p_subMenu->ModifyMenu(ID_MENU_ENABLE,MF_BYCOMMAND| MF_STRING,ID_MENU_ENABLE,(LPCTSTR)strMenuString);
ASSERT(bChanged);
///////////////////////////////
I think i m doing some thing wrong in above code
Regards
Manoj Jangid </font>
View the full article
How do i change menu item text at Runtime in MFC Dialog based application.
///my code <font size=2>
CMenu m_Menu,*p_subMenu;
CString strMenuString;
CString strTMP;
m_Menu.LoadMenu(IDR_MY_MENU);
p_subMenu = m_Menu.GetSubMenu(0);
p_subMenu->GetMenuString(ID_ENABLE,strMenuString,MF_BYCOMMAND);
strTMP.LoadString(IDS_MENU_DISABLE);
</font><font color="#0000ff" size=2>if</font><font size=2>(strMenuString.CompareNoCase(strTMP)==0)
{
strMenuString.LoadString(IDS_MENU_ENABLE);
}
</font><font color="#0000ff" size=2>else
</font><font size=2>{
strMenuString.LoadString(IDS_MENU_DISABLE);
}
BOOL bChanged = p_subMenu->ModifyMenu(ID_MENU_ENABLE,MF_BYCOMMAND| MF_STRING,ID_MENU_ENABLE,(LPCTSTR)strMenuString);
ASSERT(bChanged);
///////////////////////////////
I think i m doing some thing wrong in above code
Regards
Manoj Jangid </font>
View the full article