Link to home
Start Free TrialLog in
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!
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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)?
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

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?
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

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)...
>>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

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!


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

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!
Thanks for the feedback, glad you got it sorted out.