25

CEdit does not appear any special characters

 2 years ago
source link: https://www.codesd.com/item/cedit-does-not-appear-any-special-characters.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CEdit does not appear any special characters

advertisements

Why does CEdit control not display special characters e.g., ™ (Trademark)? For example, create a CDialog with a CEdit control and set the Dialog title and CEdit control to the same CString and get different results.

CString  s(_T("ShowTM ™"));
SetWindowText(s);           //Set Dialog Title (shows ™)
editCtrl.SetWindowText(s);  //Set Edit Control (does not show ™)

mDvE7.png

Thanks Christian and Paul. With your help I was able to piece together what was going on. The conclusion may be flawed but Visual Studio use to create dialogs with a default font property of

FONT 8, "MS Sans Serif"

MS Sans Serif is only really used by Windows Me/95/98 and is missing the characters I needed.

Today the default font is

FONT 8, "MS Shell Dlg"

MS Shell Dlg is not really a font as much as a placeholder Windows maps on to a real font later, depending on the version of Windows. Windows XP/Vista/7 etc map to Microsoft (not MS) Sans Serif which has the characters I needed.

I believe Windows was dynamically mapping MS Sans Serif to Microsoft Sans Serif for CDialog, but not CEdit, and

editCtrl.SetWindowTextW( _T("Hello ™"));

worked because new dialogs use MS Shell Dlg font and therefore get the full character set of Microsoft Sans Serif.

Given this is legacy code I have just under 200 explicit MS San Serif references that should be update to MS Shell Dlg. Yay!

For more detail on the font mapping see https://msdn.microsoft.com/en-us/library/windows/desktop/dd374112%28v=vs.85%29.aspx.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK