Using ↺ on a button in a Win32 GUI

I am creating a Win32 GUI application and I want to display the on symbol on the button.

Generally, I think you need to insert a unicode character as follows:

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 in the "C / C ++ / Java" section http://www.fileformat.info/info/unicode/char/27f3/index.htm

However, when I do this, I do not get the arrow symbol, but the other? What's wrong?

Thanks!

+4
source share
2 answers

I'm going to shamelessly steal a comment from Raymond Chen 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 selected in the window must support the character.

+8
source

Well, you can also do this, and this is not much different from @Mark Ransom's 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 UNICODE in your program as follows: -

  #define UNICODE 

Explanation: - TEXT is a macro that expands to a Unicode equivalent; if UNICODE is defined differently, it evaluates a normal ASCII string.

0
source

Source: https://habr.com/ru/post/1483070/


All Articles