Search code examples
c++charwindowconslpcwstr

Can't set windows name


So I tried to put together a window, but when I needed to name the window I told me. (Error: argument of type “const char*” is incompatible of type “LPCWSTR”) Programming for the CreateWindow method is underneath. Error should be in line 2.


hwnd = CreateWindow(
    "Engine_Winter_Name",
    "Winter Engine",
    WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION,
    GetSystemMetrics(SM_CXSCREEN)/2 - WIDTH/2,
    GetSystemMetrics(SM_CYSCREEN)/2 - HEIGHT/2,
    WIDTH,
    HEIGHT,
    (HWND)NULL,
    (HMENU)NULL,
    hInstance,
    (LPVOID*)NULL);

if (!hwnd)
    return false;

ShowWindow(hwnd, nCmdShow);

return true;

All help is more than welcome! Thanks in advance.


Solution

  • You need a wide string. Prefix your strings with L.

    hwnd = CreateWindow(
        L"Engine_Winter_Name",
        L"Winter Engine",