Avatar of pamir
pamir

asked on 

MFC resources with Cyrillic encoding

Hi,

I have a MFC project with dialogs with Cyrillic letters. I am compiling it on Windows XP with VC++ 2003.

On my system, in "Regional and language options", "Language for non-Unicode programs", the appropriate language (Bulgarian) is selected and everything is OK.

However, many users who use the application have on their systems "Language for non-Unicode programs" English. I can not force them to change that option and would like my application to work properly even in that case.

However, when "Language for non-Unicode programs" is English, some resources do not display Cyrillic characters. For example, Menus are OK but labels and buttons does not display Cyrillic characters.

What do you think is the simplest way to correct this problem?

Thanks in advance!
Editors IDEsSystem ProgrammingVisual C++.NET

Avatar of undefined
Last Comment
AndyAinscow
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of pamir
pamir

ASKER

Hi Andy, if I change my whole app to UNICODE, doesn't it mean that I have to rewrite all stuff where I have char[] functions? That will be very hard to do.

Isn't there any way to switch to UNICODE only resources (GUI)?
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

rewrite - yes, unfortunately.
resources only as UNICODE - not that I am aware of.

ps.  I haven't tested my suggestion.  IF you do decide to go that way make a test UNICODE app first (dialog with label, edit...) and see if behaves properly.  That should only take a few minutes of your time.
Avatar of pamir
pamir

ASKER

But if I have to rewrite the whole application, it will take me about several months of work. Ineed only to display several labels and buttons in Cyrillic, which is not worth so much work.

And the other impressive thing is that menus are displayed correctly, but buttons and labels are not... isn't it very strange?
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Another idea.
In the header of the dialog declare a CFont variable, eg m_FontBulgarian.
In the OnInitDialog have code like

m_FontBulgarian.Create(put the font details here - see help file)
GetDlgItem(IDC_BTN1)->SetFont(&m_FontBulgarian);  //replace IDC_BTN1 with the ID of a control, repeat for each control that doesn't show correctly.
Avatar of pamir
pamir

ASKER

I have tried this - the font changes, but unfortunately the encoding of the font does not change - don't know why. If the encoding could be changed, this would solve the problem easily...

The only way I have discovered to work is to have owner-drawn buttons - by some reason, the DrawItem function takes care about the font encoding and the text is displayed correctly. However, in this case, I have to duplicate every button and place new buttons over original ones (in order to retain their coordinates determined by the dialog resource)...
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

>>However, in this case, I have to duplicate every button and place new buttons over original ones (in order to retain their coordinates determined by the dialog resource)...

Actually no.  You can subclass the existing buttons to your ownerdraw button class, but there would be still some coding for all of the drawing - depressed, disabled...
Avatar of pamir
pamir

ASKER

>>Actually no.  You can subclass the existing buttons to your ownerdraw button class, but there would be still some coding for all of the drawing - depressed, disabled...

Unfortunately this does not work - if I subclass it, the button do not display the characters, even it is ownerdrawn!

But the most strange thing is that I have tried a test dialog application with UNICODE, and characters are not displayed again! That is awfully peculiar!


Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

I have no further ideas.
From what you say it is likely the best way is your idea to dynamically create the buttons over the existing buttons.

see in help:  GetWindowRect, ScreenToClient
Avatar of pamir
pamir

ASKER

Hi again Andy,

I have found a little mistake in my test UNICODE dialog application. The dialog was put by default in the section "English resources" instead of "Bulgarian resources". I have moved it to the right section and everything works properly.

So finally your suggestion to use UNICODE was correct. Thanks for your help!
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Thanks for the feedback, glad you got it sorted out.
System Programming
System Programming

Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.

41K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo