문제

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!

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top