Reputation: 794
I'm making a Win32 GUI application and I want to display the ↺ character on a button.
Normally, I think one would insert a unicode character like this:
HWND button = CreateWindow("BUTTON", "\u27F3",
WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, size - 105,
size - 29, 100, 24, hwnd, (HMENU)IDI_BUTTON,
GetModuleHandle(NULL), NULL);
where "\u27F3" is the unicode character described here under "C/C++/Java" http://www.fileformat.info/info/unicode/char/27f3/index.htm
However, when I do this I don't get the arrow character but a different one? What's going wrong?
Thanks!
Upvotes: 4
Views: 2835
Reputation: 6492
Well, you could also do this , also this isn't much different from @Mark Ransom answer :-
HWND button = CreateWindowW(TEXT("BUTTON"), TEXT("\u27F3"),
WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, size - 105,
size - 29, 100, 24, hwnd, (HMENU)IDI_BUTTON,
GetModuleHandle(NULL), NULL);
and define a UNICODE in your program like this :-
#define UNICODE
Explanation :- TEXT
is a macro which expands to unicode equivalent if UNICODE
is defined other wise it evaluates to normal ASCII string.
Upvotes: 0
Reputation: 308130
I'm going to shamelessly steal from Raymond Chen's comment and show the corrected code:
HWND button = CreateWindowW(L"BUTTON", L"\u27F3",
WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON, size - 105,
size - 29, 100, 24, hwnd, (HMENU)IDI_BUTTON,
GetModuleHandle(NULL), NULL);
Naturally the font you have selected into the window will need to support the character.
Upvotes: 8