Internationalizing menus using MFC support for Unicode

Environment: Windows 2000

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));
  }
}

Downloads

Download demo project - 48 Kb
Download source - 288 Kb


Comments

  • RTL strings

    Posted by Legacy on 03/03/2003 12:00am

    Originally posted by: Deepak

    HI,

    Do you know how to display the Hebrew/Arabic Strings on a owner drawn button controls. I have string 23 x 15 mm, but when I call a ExtTextOut to display the above string, it comes as a inches mm 15 23 on a button control.
    DO you ever face this problem.

    Regards
    dk

    Reply
  • Can program run on Win98

    Posted by Legacy on 12/07/2001 12:00am

    Originally posted by: NGUYEN HUU HOA

    This code is only implement on Win2000 environment. Can it run on Win98?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • QA teams don't have time to test everything yet they can't afford to ship buggy code. Learn how Coverity can help organizations shrink their testing cycles and reduce regression risk by focusing their manual and automated testing based on the impact of change.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds