kent1911
kent1911

Reputation: 1

cannot convert 'const wchar_t*' to 'LPCSTR' {aka 'const char*'}

Please help me with this code, I don't know how to change it so I can fix it and run it

std::wstring stemp = std::wstring(filename.begin(), filename.end());

hBitmapG = (HBITMAP)LoadImage(GetModuleHandle(NULL), stemp.c_str(), IMAGE_BITMAP,
                  0, 0, LR_LOADFROMFILE);

if (!hBitmapG) {
    DWORD err = GetLastError();
    std::wstring errorMsg = L"Failed to LoadImage - '" + stemp + L"', error code (" + std::to_wstring((long long)err) + L")";
    MessageBox(NULL, errorMsg.c_str(), L"WinCanvas::DrawBitmap()", MB_OK);

    PostMessage(hWnd, WM_DESTROY, NULL, NULL);    // Post a message to destroy (shutdown) the program
    return FALSE;
}

Upvotes: -2

Views: 67

Answers (1)

Shimizu Hino
Shimizu Hino

Reputation: 61

You can use MessageBoxW function to use wide characters in MessageBox.

Upvotes: 1

Related Questions