There is a self-written function in the library file connected to the main one:
HWND CreateEditor (
TCHAR * tText,
HWND hParent,
POINT pCoords = {0, 0},
SHAPE Size = {200, 50},
DWORD dStyle = WS_CHILD | WS_VISIBLE | SS_LEFT)
{
return CreateWindow ("edit", tText, dStyle, pCoords.x, pCoords.y, Size.width, Size.height, hParent, (HMENU) NULL, hInstance, NULL);
}
The main file declares:
# define _UNICODE
The compiler swears at line 10 like this:
“Cannot convert const char * to LPCWSTR for argument 2 to HWND __ * CreateWindowExW (DWORD, LPCWSTR, LPCTWSTR, int, int, int, int, HWND, HMENUHINSTANCE, LPVOID)”
Please help.
Answer 1, authority 100%
LPCWSTR
is a synonym for CONST WCHAR *
, see page msdn. In natural C++ terms, this would be const wchar_t *
. To make the string literal compatible with the mentioned type, you need to add the prefix L
, i.e. in your case use L "edit"
. You can also get by with the WinAPI macro _T
, which takes into account the presence of the project’s unicode nature. In this case, you can use the _T ("edit")
entry.
For more information, see the linked question: char * to LPWSTR