Using MSLU with ATL/WTL
(Originally posted Mar 08 2002)
If you are using the Microsoft Layer for Unicode on Windows 95/98/Me Systems
in a project that uses ATL or WTL, there are some things you need to do to make it work.
This page will act as a repository for thr things you need to know.
Avoid the _ATL_MIN_CRT macro -- this macro appears to be incompatible with MSLU.
Problems with garbage text in window title bars -- It is a problem with the usage of ::DefWindowProc and
::CallWindowProc in ATL and WTL. The way to correct this problem is to at the very start of your program add
the following code:
// Resolve UNICOWS's thunk (required)
::DefWindowProc (NULL, 0, 0, 0);
Tim Smith explained it best:
"The problem is that if you create an ATL window prior to ::DefWindowProc being called, then
m_pfnSuperWindowProc points to the thunk [in the loader] and not the resolved address. Then when ATL passes
m_pfnSuperWindowProc into ::CallWindowProc as part of the WM_SETTEXT message, MSLU doesn't realize that it is
being passed [its own] ::DefWindowProc and thus does an extra level of text conversion. By invoking ::DefWindowProc at
the start of the program, then when ATL creates a window and stores the address of ::DefWindowProc in
m_pfnSuperWindowProc, it is storing the address of the MSLU routine that the MSLU ::CallWindowProc realizes
does not need conversion. In general, if you are using ATL/WTL, just add that line of code at the start of
your program and be done with it. It also should be added to any DLL that uses ATL windows [which have the same issue].
Please note that the abvove issue has been addressed in WTL 7.0
and thus only applies to earlier versions of WTL.
As people find more issues, this page will be updated.
Problems with this site? Please contact the firstname.lastname@example.org
with your comments, questions, or suggestions.