The MASM Forum

General => The Workshop => Windows API => Topic started by: jj2007 on November 21, 2023, 08:53:10 AM

Title: Static control refuses to display Unicode
Post by: jj2007 on November 21, 2023, 08:53:10 AM
This cost me half a day of bug chasing, so I'll share the solution with you:

I have a static control that until recently worked fine, displaying Russian text (my favourite test language). Then it stopped and showed only ???????...

Long story short: the control is subclassed using...

mov opControl, rv(SetWindowLong, hStatic, GWL_WNDPROC, offset WndProcChild)
...
invoke CallWindowProc, opControl, hWnd, uMsg, wParam, lParam

Straightforward, isn't it? But it shows ???? where Документ was expected. One single char more solved the problem: SetWindowLongW
Title: Re: Static control refuses to display Unicode
Post by: NoCforMe on November 21, 2023, 09:38:07 AM
Good catch. Moral of the story: know thy Unicode from thy ANSI. (I've never used SetWindowLongW(), since I don't have to mess with that Unicode stuff.)
Title: Re: Static control refuses to display Unicode
Post by: jj2007 on November 21, 2023, 11:20:09 PM
Setting and displaying Russian was the only problem with the subclass, everything else worked as usual.

It's weird that Windows apparently provides two subclassing options (https://learn.microsoft.com/en-us/windows/win32/intl/subclassing-and-automatic-message-translation):

QuoteThe operating system automatically translates messages into Windows (ANSI) code page or Unicode form, depending on the form of the function that has subclassed the window procedure.
Title: Re: Static control refuses to display Unicode
Post by: TimoVJL on November 21, 2023, 11:23:20 PM
Quote from: jj2007 on November 21, 2023, 11:20:09 PMSetting and displaying Russian was the only problem with the subclass, everything else worked as usual.
As usual with ... :biggrin: