right so I'm new to creating windows applications as I have mostly used console up until this point. I'm confident with the ideas and understand OOP and have been using MSDN to create a simple window.
As you can see the characters used are not the same. Using MSDN I've found that the character set for LPCSTR is ANSI and I'm fairly sure VS uses Unicode so I'm not sure if that is the issue or not
If anyone can tell me why that would be great!
CodePudding user response:
You are explicitly using the A
version of functions when registering and creating your window (RegisterClassExA()
and CreateWindowExA()
, respectively), but you are using the TCHAR
-based DefWindowProc()
macro when specifying your window procedure. You are likely compiling your project with UNICODE
defined, thus the DefWindowProc()
macro would map to the DefWindowProcW()
function instead of DefWindowProcA()
.
This mismatch will cause the behavior you are seeing, as explained in Raymond Chen's blog article:
Why am I getting mojibake when I try to create a window?
The solution is to use DefWindowProcA()
explicitly instead, to match with the rest of your code logic:
//wc.lpfnWindowProc = DefWindowProc;
wc.lpfnWindowProc = DefWindowProcA;
CodePudding user response:
Just change the character set to multi-byte and it'll work.