According to the documentation, WM_CHAR
sends a character code in wParam
. The first paragraph in the Remarks section says that the code is indeed Unicode UTF-16 codepoint. This is same whether you are compiling your code for 8 or 16 bit TCHAR.
CodyGray's comment is correct in the part that CString
supplies a variety of constructors. The one you are looking for is that which takes a wchar_t
as its first argument (the second argument, the repetition count, is set to 1 by default). Therefore, to construct a CString
out of a WPARAM
, you cast the value to wchar_t
. The following sample prints "0", confirming that the constructed string is indeed what it is expected to be.
#include <stdio.h>
#include <Windows.h>
#include <cstringt.h>
#include <atlstr.h>
int main ()
{
WPARAM w = 0x222D;
CString cs ((wchar_t)w);
printf ("%d", cs.Compare (L"\x222D"));
}
It will work same and in both _UNICODE and ANSI compilation modes, and is portable accross 32 and 64 bitness.