Help - Бесконечный цикл в запускателе C++

Olympicus

Интересующийся
Участник
Сообщения
75
Розыгрыши
0
Решения
2
Репутация
42
Реакции
33
Баллы
375
Hi, I've been trying to make my life a little more miserable for a few days now and I'm trying to compile this C++ code. I should clarify that my knowledge of C++ is zero and even Visual Studio is unfamiliar to me (Yes, I'm a Notepad++ user). After following a few tutorials and YouTube videos, I was able to compile the code without errors, but when I run the updater, it throws up a "Failed to create window" message. Googling and checking the code, it looks like the window is never registered. After applying some changes suggested by ChatGPT, the updater runs without that error, but eventually gets stuck in an infinite loop, collapsed, and nothing happens.


C++:
WNDCLASSEXW wcex;
    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = _WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_CPP_GAME_LAUNCHER);
    wcex.lpszClassName = Constants::GUID.c_str();
    RegisterClassExW(&wcex);

    hWnd = CreateWindowExW(0, Constants::GUID.c_str(), szWindowTitle, WS_POPUP | WS_MINIMIZEBOX,
        windowX, windowY, windowWidth, windowHeight, nullptr, nullptr, nullptr, nullptr);

    if (!hWnd)
        throw std::logic_error("Failed to create window!");
Any recommendations or advice are welcome. I want to clarify that for the libraries I use vcpkg and Visual Studio 2022 (maybe this can cause some conflict (?))

 

Need to know exact error after handle failed to create.

Replace

C++:
throw std::logic_error("Failed to create window!");

with

C++:
throw std::runtime_error("Failed to create window: " + std::system_category().message(GetLastError()));

and provide error message you got
 
Назад
Сверху Снизу