Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made simple edit control. After I change keyboard layout from English to other one, characters are not shown properly. They are represented with a pipe ( | ).

If I copy the content of the edit control and paste it into Notepad they are displayed properly.

I have tried to register class / create parent window / create edit control with suffix W ( CreateWindowExW / RegisterClassExW ) but no luck...

I have typed specific UNICODE characters in my source file so a dialog box in Visual Studio can pop prompting me to save all my files as UNICODE. Once it popped I confirmed to save everything as UNICODE. I have also went to Project properties and selected UNICODE character set.

No progress... You can reproduce the problem by simply creating the edit control, and then changing keyboard layout so there is no need for SSCCE. I work on Windows XP using Visual Studio 2008.

If anything else I must provide / do please ask.
Posted
Comments
Rage 30-May-14 8:57am    
Are you using MFC ?
AlwaysLearningNewStuff 31-May-14 10:33am    
No, just raw WinAPI.

1 solution

After adding the following code snippet into my WM_CREATE handler I found out that edit control uses System font :

C++
HFONT hf = (HFONT)SendMessage( hEdit, WM_GETFONT, 0, 0 );

HDC eDC = GetDC( hEdit );
wchar_t txt[50];
GetTextFace( eDC, 50, txt );

SetWindowText( hEdit, txt );

ReleaseDC( hEdit, eDC );
DeleteObject( hf );


After choosing this same font in Notepad, the problem was reproduced.

Thus, after adding the following code just below the code I submitted above, the problem was fixed :

C++
SendMessage( hEdit, WM_SETFONT, 
    (WPARAM)( (HFONT)GetStockObject(DEFAULT_GUI_FONT) ), 0 );


So the answer to my question is :

The problem is font, thus it must be changed to the one that can show special characters I need to display.

Hopefully this will save someone the trouble.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900