菜单的中英文转换解决方案
菜单的中英文转换
CWnd *pWnd;
CMenu* menu = GetMenu();
if(menu==NULL)
return;
int nCount = menu->GetMenuItemCount();//获取该层菜单数
for(int i=0;i<nCount;i++)//遍历所有菜单项
{
int id = menu->GetMenuItemID(i);//查看菜单属性,id=0为分割线,-1为popup菜单
if(id==0)
{}
else if(id==-1)
{
CString strText;
menu->GetMenuString (i, strText, MF_BYPOSITION);//获取菜单文字
CString cs = AfxGetApp()->GetProfileString(_T("menu"),strText,strText);//读取菜单项在ini里的文字
menu->ModifyMenu(i,MF_STRING|MF_BYPOSITION,id,cs);
CMenu* pSub = menu->GetSubMenu(i);
}
else
{
CString strText;
menu->GetMenuString(i,strText,MF_BYPOSITION);
strText.Replace(_T('\t'),_T('_'));//解决'\t'无法使用GetProfileString的问题
CString cs = AfxGetApp()->GetProfileString(_T("menu"),strText,strText);
cs.Replace(_T('_'),_T('\t'));//把上面的replace再变回来
menu->ModifyMenu(i,MF_STRING|MF_BYPOSITION,id,cs);
}
这段代码是菜单的中英文转换...但不知道哪里出了问题..就是不能实现...请各位高手帮忙看看!!
------解决方案--------------------
一步一步教你用VC纯资源dll解决国际化问题
http://www.vckbase.com/document/viewdoc/?id=1567
------解决方案--------------------
需要动态切换还是静态?
CWnd *pWnd;
CMenu* menu = GetMenu();
if(menu==NULL)
return;
int nCount = menu->GetMenuItemCount();//获取该层菜单数
for(int i=0;i<nCount;i++)//遍历所有菜单项
{
int id = menu->GetMenuItemID(i);//查看菜单属性,id=0为分割线,-1为popup菜单
if(id==0)
{}
else if(id==-1)
{
CString strText;
menu->GetMenuString (i, strText, MF_BYPOSITION);//获取菜单文字
CString cs = AfxGetApp()->GetProfileString(_T("menu"),strText,strText);//读取菜单项在ini里的文字
menu->ModifyMenu(i,MF_STRING|MF_BYPOSITION,id,cs);
CMenu* pSub = menu->GetSubMenu(i);
}
else
{
CString strText;
menu->GetMenuString(i,strText,MF_BYPOSITION);
strText.Replace(_T('\t'),_T('_'));//解决'\t'无法使用GetProfileString的问题
CString cs = AfxGetApp()->GetProfileString(_T("menu"),strText,strText);
cs.Replace(_T('_'),_T('\t'));//把上面的replace再变回来
menu->ModifyMenu(i,MF_STRING|MF_BYPOSITION,id,cs);
}
这段代码是菜单的中英文转换...但不知道哪里出了问题..就是不能实现...请各位高手帮忙看看!!
------解决方案--------------------
一步一步教你用VC纯资源dll解决国际化问题
http://www.vckbase.com/document/viewdoc/?id=1567
------解决方案--------------------
需要动态切换还是静态?