Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi! I'm reworking on an old project(not started by me). I'm replacing the old dialog with a frame, so that I can put a ribbon instead of the menubar(that's the task). So... The original project doesn't work with Unicode, but in the frame's OnCreate method I need widechar strings for this fragment to work correctly:
    CString strTitlePane1;
CString strTitlePane2;
bNameValid = strTitlePane1.LoadString(IDS_STATUS_PANE1);
ASSERT(bNameValid); //here I get a runtime error
bNameValid = strTitlePane2.LoadString(IDS_STATUS_PANE2);
ASSERT(bNameValid);


LoadString is defined as LoadStringA since the project works with ANSI and this mustn't be changed globally. Somebody? :/

P.S. I'm still not quite sure if this is exactly the problem :/
Posted
Updated 3-Dec-13 0:27am
v2

I would suggest that you convert the part that does not works presently to works in Unicode.

We are almost in 2014 so you are more than 10 years late to convert your application to Unicode. In 2000's, it was already possible to write Unicode program on Win 9x using Microsoft Layer for Unicode on Windows 95/98/ME Systems.

I guess that it is a very old application as application created after around year 2000 has essentially not reason to have been created in ANSI.

In my opinion, either you only make bug fixes (thus no new ribbon) and keep ANSI code or you make the application modern and convert it to Unicode.

If the application uses file then it should convert old ANSI file to Unicode either at opening or when required. It might make sense to use UTF-8 for file encoding as it is typically smaller.
 
Share this answer
 
I simply had forgotten to describe the needed items in the .rc file :D
 
Share this answer
 
Comments
Albert Holguin 5-Dec-13 16:30pm    
Happens...
i do that this way:

CStringW strTitlePane2;
bNameValid = strTitlePane1.LoadStringW(IDS_STATUS_PANE1)

look out for the two "W" in the code :-O

or is the problem an invalid strind id of IDS_STATUS_PANE1 ???
 
Share this answer
 
v2
Comments
StoyanovZ 3-Dec-13 12:04pm    
Oh, right, I haven't tried it this way yet :D By the way, I'm starting to thing more and more that it has nothing to do with it, because anyway LoadString is BOOL. BUT IDS_STATUS_PANE1 is defined(I think it's sort of 40235), so it does exist... I'm not quite sure what's going on here :/
StoyanovZ 3-Dec-13 12:08pm    
Now that I think of it again... Is resource.h the only place we give numbers to the IDs?
KarstenK 4-Dec-13 4:48am    
change the id AND the number to test it - i think this id comes from some MS header :-O
[See this post]
You can have problem with enconding charset.
 
Share this answer
 
Comments
StoyanovZ 3-Dec-13 12:07pm    
Thanks! I'll try this tomorow(I'm on another computer now)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900