标识符“ImGui_ImplWin32_WndProcHandler”未定义且未找到

问题描述 投票:0回答:1
#include <pch.h>
#include <dwmapi.h>
#include "imgui/imgui.h"
#include "imgui/imgui_impl_dx9.h"
#include <chrono>
#include <thread>
#include "settings.h"
#include <d3d9.h>
#include "Imgui/imgui_impl_win32.h"
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "dwmapi.lib")


// Variable definitions
IDirect3D9Ex* p_object = nullptr;
IDirect3DDevice9Ex* p_device = nullptr;
D3DPRESENT_PARAMETERS p_params = { NULL };
MSG messager = { nullptr };
HWND my_wnd = nullptr;

// Function implementations
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (ImGui_ImplWin32_WndProcHandler(hwnd, msg, wParam, lParam))
        return true;

    switch (msg)
    {
    case WM_SIZE:
        if (p_device != NULL && wParam != SIZE_MINIMIZED)
        {
            p_params.BackBufferWidth = LOWORD(lParam);
            p_params.BackBufferHeight = HIWORD(lParam);
            p_device->Reset(&p_params);
        }
        return 0;
    case WM_SYSCOMMAND:
        if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
            return 0;
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
}

HRESULT directx_init()
{
    if (FAILED(Direct3DCreate9Ex(D3D_SDK_VERSION, &p_object)))
        return E_FAIL;

    ZeroMemory(&p_params, sizeof(p_params));
    p_params.Windowed = TRUE;
    p_params.SwapEffect = D3DSWAPEFFECT_DISCARD;
    p_params.hDeviceWindow = my_wnd;
    p_params.BackBufferFormat = D3DFMT_A8R8G8B8;
    p_params.BackBufferWidth = settings::width;
    p_params.BackBufferHeight = settings::height;
    p_params.EnableAutoDepthStencil = TRUE;
    p_params.AutoDepthStencilFormat = D3DFMT_D16;
    p_params.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

    if (FAILED(p_object->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, my_wnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &p_params, nullptr, &p_device)))
    {
        p_object->Release();
        return E_FAIL;
    }

    ImGui::CreateContext();
    ImGui_ImplWin32_Init(my_wnd);
    ImGui_ImplDX9_Init(p_device);
    //ImGui::GetIO().Fonts->AddFontFromFileTTF("include//font.otf", 18.0f);

    p_object->Release();
    return S_OK;
}

void create_overlay()
{
    WNDCLASSEXA wcex = {
        sizeof(WNDCLASSEXA),
        CS_CLASSDC,
        WindowProc,
        0,
        0,
        GetModuleHandle(NULL),
        LoadIcon(0, IDI_APPLICATION),
        LoadCursor(0, IDC_ARROW),
        0,
        0,
        "OverlayWindowClass",
        LoadIcon(0, IDI_APPLICATION)
    };
    RegisterClassExA(&wcex);

    ImGui::SetNextWindowSize({ 620, 350 });
    ImGui::Begin("FREE", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoTitleBar);

    ImGui::End();
    ImGui::EndFrame();
}

当我尝试构建时,我从标题中得到了上面的错误,但是当我执行 #include Imgui/imgui_impl_win32.cpp" 时,我收到了 14 个错误,指的是 .obj 文件,我现在编码有点菜鸟,所以请帮忙将不胜感激:)

我尝试过包含该目录,但是我收到了引用 .obj 文件的错误

user-interface render dma imgui
1个回答
0
投票

我遇到了完全相同的问题,但找不到任何论坛来帮助我,希望有人能尽快回答。每当我向人工智能寻求帮助时,它都会告诉我检查我的后端是否包含在内,没有其他方法可以解决这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.