Frage

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

War es hilfreich?

Lösung

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());

Andere Tipps

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";

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top