Click here to Skip to main content
15,893,487 members
Articles / Desktop Programming / MFC
Article

Working with Unicode and MSLU - Common Problems

Rate me:
Please Sign up or sign in to vote.
1.77/5 (7 votes)
30 Jul 2008CPOL2 min read 17.1K   7   1
The following description briefs you on common problems you might come across while working with MSLU (Microsoft Layer for Unicode)

Introduction

The articles describes some of the common issues you'd come across while working with MSLU using MFC/Win32.

Background

Creating Unicode applications has always been an encouraging factor for developer and the users. However, the problem is the difficulty in supporting a Unicode application on Non-Unicode Windows Operating Systems (Windows 95/98/ME); developers had to support those customers as well. Because these platforms were not intended to support Unicode, which was introduced by the NT family of operating systems, the fallback was to write non-Unicode applications.

I have attempted to put across some of the common problems you would encounter, and how you can tackle them.

Working with MSLU — Common Problems

  1. The CListCtrl controls in your application might not display the contents properly. this can happen with some other common windows controls. This is due to the fact that control notifications format for Unicode needs to be set specifically. We handled the WM_NOTIFYFORMAT message and explicitly return NFR_UNICODE for UNICODE configurations and returns NFR_ANSI for Non-UNICODE configurations.

    C++
    LRESULT CSampleDlg :: OnNotifyFormat(WPARAM wParam, LPARAM lParam)
    {
    #ifdef _UNICODE
        return NFR_UNICODE;
    #else
        return NFR_ANSI;
    #endif
    }
  2. On Windows 98/ME, CRichEditCtrl doesn’t show the Unicode text, as it uses version 1.0 of CRichEditCtrl (window class RICHEDIT). The solution is to use version 2.0 (window class RICHEDIT20W). Changed the .rc file (resource script), so that "IDC_RICHEDIT_..." to refer to "RICHEDIT20W" class instead of "RICHEDIT".... Thats all....

  3. On Windows 98 system, another issue was, we were not able to get the tool tips for some of the controls. This also needs NOTIFYFORMAT to be handled as described in point
  4. Another problem is with the use of Set/GetMenuString and Set/GetMenuItemInfo functions on windows 98 system. This happens as the GetMenuItemInfoW function sometimes returns ANSI strings rather than Unicode ones. The workaround is to either use the GetMenuItemInfoA function or to use the MSLU GetMenuStringW function, which will work properly here. An error affecting InsertMenuItemW and SetMenuItemW was fixed at the same time (the MENUITEMINFO.cch member was being used to get the string length even though setting it is not required in those APIs).

References

History

Version 1.0 --- 30/Jul/2008

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
auge__22-Mar-10 5:22
auge__22-Mar-10 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.