I use the DialogBox API to display a dialog at my application. In the WM_INITDIALOG message handling at the DLGPROC procedure call back, I could see the text string is correct Unicode at debugger and SetDlgItemText is used to set the text on Rich Edit control in the dialog. However when I tried to get the text from dialog by using GetDlgItemText API , it was all question marks for those characters.
My project is compiled as Unicode. And I also used the spy++ and it shows the Windows Proc is Unicode.
I am testing Chinese on Windows 7 with English Locale, so I also installed the Chinese Language Pack for my machine and it doesn’t help either.
I could not explain what I see here. It would be appreciated if any one could shed some lights on this or how to debug further.
It turns out that it is due to the RichEdit control there. If I just use a text box, the Chinese characters would be displayed correctly along with other English characters. So after doing some reading, particular this one, I gave some tries and I got it working. So basically I should not use SetDlgItemText, instead I should use the following code (where m_strDisplay is the text to display on rich edit):
to set the text on RichEdit control.