Question

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

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top