-2

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;
}
  • A question that gets asked literally every single day. May want to do some research up front. And since you are clearly *completely* unfamiliar with the Windows API, consider using standard tooling (Visual Studio). It'll make discovering solutions so much easier. – IInspectable Sep 10 '22 at 08:20

1 Answers1

1

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