loadstring fails in MBCS encoding

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,

Implementation of CString::LoadString has changed from VC6 to VC7 and I
can't load MBCS resources correctly any more.
When I translate the application to Russian or Chinese languages, dialogs
and menus and all strings defined directly in the resource file are well
displayed but
the problem is when I have to load dynamicaly some resources like this :

CString s;
s.LoadString (MY_ID_RESOURCE);
m_edit.SetWindowText(s);

Then, the string will be "????????" instead of the rigth one.

Debugging, I have found that in VC7 LoadString implementation makes a
conversion with a call to ConvertToBaseType method.

I have found two solutions :

the first one is to use TCHAR instead of CString :

TCHAR buf[255];
LoadString(NULL, MY_ID_RESOURCE, buf, 255);
m_edit.SetWindowText(buf);

the second one is to change properties of the project by changing Character
Set from MBCS to Unicode.

Unfortunatly, neither of the two solutions are possible.

The first one cannot be used because there are also dynamic loads in mfc
code (like for the title of the main frame).

The second one makes two much changes in the code of the application which
is two large.

Does any body has an idea ?
Thanks in advance.
Selena






.



Relevant Pages

  • RE: Net runtime crash
    ... > user controls and worked under massive requests load: ... > resources and updated all cache entries (we use server cache ... > debugging tools, some tools to get more descriptive event source ...
    (microsoft.public.dotnet.framework.aspnet)
  • Net runtime crash
    ... We developed ASP.Net application that run on production server, ... Failed to load resources from resource file ... debugging tools, some tools to get more descriptive event source ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Embeeded resources Vs. Content files
    ... > large assembly during load. ... JITing occurs at the method level as and when the method is ... As for the issue of content vs embedded resources, I haven't looked at it in ... from where I would load all the images my application ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Resources
    ... load resources from an assembly other than the currently executing one. ... The first mechanism relies on you knowing only the name of the assembly ... > How can i read resources/strings from one EXE to another? ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: delete this
    ... "Allan Bruce" wrote in message ... > VC7 but I want to know if this is generally or portably ok. ... of resources you may use in the class at the destructor. ...
    (comp.lang.cpp)