Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

Create menus with Unicode, ModifyMenu, GetSubMenu

Added 29 Jul 2008

This simple SDI Notepad-like application demonstrates how, taking advantage of the MFC support for Unicode, to Turkmenize labels of the specified menu items. Actually, Turkmen is not supported by Windows 2000, therefore, to create such resources as menu so that strings in Turkmen could be displayed I had to invent an additional technique.

void CMainFrame::ModifyMenu(CMenu* pMenu)
{
UINT nPosition;
UINT nCount;
CString string;

nCount = pMenu->GetMenuItemCount();

for (nPosition = 0; nPosition < nCount; nPosition++)
{

pMenu->GetMenuString(nPosition,string,MF_BYPOSITION);
if(string.IsEmpty())
continue;

string.Replace(SMALL_X, Small_S_cedilla[0]);
string.Replace(CAPITAL_X, Capital_S_cedilla[0]);
string.Replace(SMALL_Q, Capital_N_caron[0]);

pMenu->ModifyMenu(nPosition,MF_BYPOSITION|MF_STRING,
pMenu->GetMenuItemID(nPosition),string);

//recursive call
if(pMenu->GetSubMenu(nPosition))
ModifyMenu(pMenu->GetSubMenu(nPosition));
}
}