I have a problem using WM_SETFONT to set a font for controls within a dialog. In my company's application (which is a CAD like MDI application using MFC with lots of dialogs) each document can set its own font to be used for drawing and even for edit controls in dialogs - thus it's i.e. possible to set one drawing to use 'Western' character set for one document and 'Cyrillic' for another one, both can be opened at the same time and, when opening a dialog to edit an object the dialog's edit controls use the appropriate font.
This worked quite fine for a long time, but now I have to make some changes which produce problems which drive me really crazy:
1. I have to add use of new version 6 of ComDlg32.dll to improve the GUI to have a more modern look, i.e. for progress bars - I do it by adding this line:
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='188.8.131.52' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
2. I need to do the same now for some other controls (CListBox, CListCtrl, CTreeCtrl, CComboBox, CMFCComboBox within CMFCToolBar, maybe more ...)
I have problems with both requirements:
1. As soon as I use the new ComDlg32.dll the previously working change of the character set for edit controls stops working. I can set a new font to the edit controls and most attributes (i.e. I tested font name, size, width, weight, underline, italic) of the new font are used, but the applied character set isn't used!
2. With or without the new ComDlg32.dll the same as in 1. written (so I can change anything but the character set) happens for all kind of controls except edit controls (including the edit control part of comboboxes, but not its list box part).
The font changes are made by creating a new font, the character set selection is done by setting the 'LOGFONT::lfCharSet' member to an appropriate value.
I have no idea why the controls don't use the character set of the font I set with WM_SETFONT nor how it is implemented in Windows - IMO this can only be done by creating a new font as a copy from the assigned one within the drawing function where for any reason the 'lfCharSet' is not used - this is very strange.
To give a better idea what's the problem about I added a screenshot below - on the left side you can see the dialog without new ComDlg32.dll (the red marked area marks the controls where the strings are partially shown correct), on the right side it's the same dialog using new ComDlg32.dll. The string I set contains both german and cyrillic characters to demonstrate the problem. Especially the possibility to mix character sets of different languages is a very important feature.
I can only see two possible solutions:
a.) Use UNICODE
b.) Override control drawing function by either handling WM_PAINT or, where available, owner drawing
But unfortunateley we either cannot or don't want to use them because
a.) It's a very large project (it contains about 10 executables including server app, some clients, about 80 DLLs use by the executables, all together about 1-1,5 Million lines of code) which is developed over the last 12 years - porting to UNICODE IMO is a matter of some man-years and, which is more important, will break the file- and database formats which is a no-go.
b.) As told there are a lot of dialogs where this needs to be done (more than one hundred) - lots of them already use owner drawn controls so it's just about finding a solution for each kind of above mentioned controls, each of the already owner drawn controls would need extra implementation. And for use of new ComDlg32.dll we even would have to implement drawing (by handling WM_PAINT) for edit controls which I know is difficult (I tried this once and didn't get it done without at least some small drawing errors i.e. with selected text and auto scrolling (but maybe this could be solved, I'm not sure) - anyhow, this even would mean a very huge amount of work so we really would like to avoid it.
I even tried to find a way to solve this by changing locales, but 1. I didn't manage to get it working and 2. it's not really an option, because font of some controls must not be changed, i.e. static texts, buttons, captions, ...
Sorry for this very long description, but I want to give as much important information as possible.
If anyone of you has an idea what I can try to find a solution I would highly appreciate it - and I can/will give lot of extra points to any helpful comment.
If you're interested in the test application I used for the screenshot please tell me, I can post it here if needed (it's done with VS 2010).
Thanks in advance,