0
  1. How do I get a HDC for use in a simple code such as this?

I tried copying the code from MSDN: Obtaining a Private Display Device Context, but the compiler throws some errors like:

a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR"

which I have no clue how to fix, as

  1. I could not find any tutorials on gdiplus that do not require some other previous knowledge.

Can anyone help me with 1 or 2?

Tau
  • 496
  • 4
  • 22
  • The first error is easily searchable in Google. As for tutorials requiring previous knowledge, have you thought about obtaining it first, then? – Bartek Banachewicz Feb 06 '18 at 13:54
  • Also, why do C++ libraries use such cryptic all-caps identifiers? As an outsider, I can not see what "LPCWSTR" could possibly mean. – Tau Feb 06 '18 at 13:55
  • 1
    It's not "C++ libraries", this convention is used by the WinAPI code. Again, easily google'able, or you could, y'know, just open WinAPI docs. – Bartek Banachewicz Feb 06 '18 at 13:57
  • @BartekBanachewicz : [Google](https://www.google.de/search?source=hp&ei=77N5Wp2lCYHcwQL-1qPQDg&q=c%2B%2B+get+hdc&oq=c%2B%2B+get+hdc&gs_l=psy-ab.3..0i19k1j0i22i30i19k1l3.1432.1432.0.2003.1.1.0.0.0.0.94.94.1.1.0....0...1c.1.64.psy-ab..0.1.92....0.-IUyIOBKcW8) does not return anything I understand; and the problem is that I don't know _what_ I should learn in the first place. – Tau Feb 06 '18 at 13:57
  • This is specifically Windows you are complaining about. Sometimes you have to google stuff over and over to learn it. Before this thread I had never seen `LPCWSTR` either, but the `STR` part clued me that it might be string related. – Gillespie Feb 06 '18 at 13:58
  • @TauCraft Try googling "winapi hdc tutorial"... Sometimes you gotta try different combinations of keywords to find the right thing https://www.codeproject.com/Articles/1988/Guide-to-WIN-Paint-for-Beginners – Gillespie Feb 06 '18 at 14:02
  • @TauCraft (1) The error has nothing to do with HDC, so you can safely forget about HDC for a moment. Now, the "googlable" error that you've got is a fairly common one for people who begin with Windows programming. It has nothing to do with C++. The key is to find out what is LPCWSTR and why it char* cannot be converted to it. Give yourself 30 min to solve this issue first. If you can't, come back and tell us. – Ivan Aksamentov - Drop Feb 06 '18 at 14:18
  • @TauCraft (2) For second question, GDI is obsolete. You will never find any decent modern tutorial. What is your usecase for GDI? We may advice you a better alternative. If you insist on raw Windows API, Charles Petzold's books are the golden standard, plus MSDN docs of course (beware, MS's docs may contain errors). – Ivan Aksamentov - Drop Feb 06 '18 at 14:20

1 Answers1

1

The error is saying that you are trying to assign a const char* to a LPCWSTR which are two different data types. Due to your lack of code we cannot directly help you.

However, please do look at something like the following answer for reference on this type of issue; cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}'

Mark Diedericks
  • 331
  • 1
  • 9