Jynzxs
Jynzxs

Reputation: 31

Why is GWL_WNDPROC undefined?

This is the only error I'm receiving, and can't seem to find a fix for it. windows.h and Winuser.h are included, so I don't think it's that.

DWORD WINAPI MainThread(LPVOID param)
{
    HWND  window = FindWindowA(NULL, windowName);

    oWndProc = (WNDPROC)SetWindowLongPtr(window, GWL_WNDPROC, (LONG_PTR)WndProc);

    IDirect3D9 * pD3D = Direct3DCreate9(D3D_SDK_VERSION);

    if (!pD3D)
        return false;

    D3DPRESENT_PARAMETERS d3dpp{ 0 };
    d3dpp.hDeviceWindow = window, d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD , d3dpp.Windowed = TRUE;

    IDirect3DDevice9 *Device = nullptr;
    if (FAILED(pD3D->CreateDevice(0, D3DDEVTYPE_HAL, d3dpp.hDeviceWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &Device)))
    {
        pD3D->Release();
        return false;
    }

Upvotes: 2

Views: 4816

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597036

When using SetWindowLongPtr(), the correct value to use is GWLP_WNDPROC, not GWL_WNDPROC, per the documentation. GWL_WNDPROC is used with SetWindowLong() instead.

GWL_WNDPROC and GWLP_WNDPROC are both defined in winuser.h. However, GWL_WNDPROC is not defined if _WIN64 is defined. Which makes sense, as SetWindowLong() is not available in a 64-bit flavor. SetWindowLongPtr() was introduced to support 64-bit.

Upvotes: 8

Related Questions