문제

I'm trying to draw text to a window. Some enough, two things I'm wondering. Why can the tutorial I'm using not put an L"String Here" and I have to?

I'm confused about that, anyway back to the main point, I;m trying to draw text and I'm getting an error.

enter image description here

도움이 되었습니까?

해결책

If you have UNICODE defined in your project (which you should be default) then you can either use

wstring s = L"Hello, World!";

or the ANSI API for TextOut

TextOutA(hdc, 10, 10, s.c_str(), s.size());

다른 팁

See the following question:

What does LPCWSTR stand for and how should it be handled with?

Basically, you're trying to convert a regular character string to a wide character string implicitly and it won't allow you to do that. From the top answer:

To get a normal C literal string to assign to a LPCWSTR, you need to prefix it with L

LPCWSTR a = L"TestWindow";

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