Discussion:
Standard MFC controls behave different when showing polish characters
(too old to reply)
s***@pks.de
2006-10-26 13:58:42 UTC
Permalink
Hello all,

I have a rather simple to describe but difficult to solve problem.
Our customers want to use our ANSI MFC program to show different
languages.
For example Polish.
When I set the font for the different controls they behave different.

For example the CEdit shows the polish characters just right but the
CButton with checkbox style shows glyphs instead of the special
characters.
Every control that is owner draw and uses for example the DrawText()
function of the device context shows the characters right.

I've experimented with _UNICODE for the display part and everything I
could think of but cannot find a solution.
Where is the difference, or what can I do (beside making all controls
owner draw) to get all controls display the same text?

What is the difference between standard control drawing or
CDC:DrawText(..)?

It is no option to rewrite all the text manipulating functions to use
the UNICODE counterparts. Because the program is half C and half C++.
It would take several weeks to work over all the source code to rewrite
everything to UNICODE and not to speak of testing everything all over
again.

Any ideas?

Thanks,
whiteman
David Lowndes
2006-10-26 17:53:05 UTC
Permalink
Post by s***@pks.de
When I set the font for the different controls they behave different.
How are you setting the font for the controls?
Post by s***@pks.de
For example the CEdit shows the polish characters just right but the
CButton with checkbox style shows glyphs instead of the special
characters.
What's different about how you set the font's for those controls?
Post by s***@pks.de
Every control that is owner draw and uses for example the DrawText()
function of the device context shows the characters right.
I've experimented with _UNICODE for the display part and everything I
could think of but cannot find a solution.
Have you got both _UNICODE and UNICODE defined?

Which OS are you testing on?
Post by s***@pks.de
It is no option to rewrite all the text manipulating functions to use
the UNICODE counterparts.
OK, so you're stuck with a non-Unicode application. Presumably your OS
is set up to support Polish correctly? Do other applications display
those characters correctly or not?

Dave
Tom Serface
2006-10-26 21:25:28 UTC
Permalink
If the string is Unicode you may want to try using SetWindowTextW() to set
the button's text. If the text is ANSI SetWindowText() will work OK. You
may not be able to use the typical DDX stuff to put a Unicode string on an
MBCS button since it wouldn't translate it correctly.

Tom
Post by s***@pks.de
Hello all,
I have a rather simple to describe but difficult to solve problem.
Our customers want to use our ANSI MFC program to show different
languages.
For example Polish.
When I set the font for the different controls they behave different.
For example the CEdit shows the polish characters just right but the
CButton with checkbox style shows glyphs instead of the special
characters.
Every control that is owner draw and uses for example the DrawText()
function of the device context shows the characters right.
I've experimented with _UNICODE for the display part and everything I
could think of but cannot find a solution.
Where is the difference, or what can I do (beside making all controls
owner draw) to get all controls display the same text?
What is the difference between standard control drawing or
CDC:DrawText(..)?
It is no option to rewrite all the text manipulating functions to use
the UNICODE counterparts. Because the program is half C and half C++.
It would take several weeks to work over all the source code to rewrite
everything to UNICODE and not to speak of testing everything all over
again.
Any ideas?
Thanks,
whiteman
whiteman
2006-10-27 07:29:39 UTC
Permalink
Post by Tom Serface
If the string is Unicode you may want to try using SetWindowTextW() to set
the button's text. If the text is ANSI SetWindowText() will work OK. You
may not be able to use the typical DDX stuff to put a Unicode string on an
MBCS button since it wouldn't translate it correctly.
Tom
I'm setting the font like this:

aButton.SetFont( kCfgAttr.GetFont() );

And setting the text with:

aButton.SetWindowText(_T(aString));

The text I set is always ANSI because the underlying socket layer is
completely written using ANSI functions.

What puzzles me is why does this

pDC.DrawText(strText, LeftAlignRect,
DT_SINGLELINE|DT_LEFT|DT_VCENTER);

work and the normal CEdit also but most other controls do show glyphs?
Where is the conversion taking place?

I already tried converting the Text to UNICODE with
MultiByteToWideChar() but that didn't help me either.

I'm glad about any hint or idea you could give me.

Thanks,
whiteman
Miles Davies
2013-08-19 08:34:21 UTC
Permalink
[snip]

If a font does not have support for a glyph it will display either [] or ?. The standard western European fonts do not support the special polish characters.

Some system fonts, such as "Tahoma" or "Microsoft Sans Serif" will detect that the font does not support a character and substitute a font that does.

I suspect which font has more import than which control as they will all use GDI to render text eventually.

See: http://blogs.msdn.com/b/michkap/archive/2005/10/01/476022.aspx
Loading...