0
我想獲得SDL2窗口的句柄,以便在WinApi中使用它。獲取SDL 2應用程序的窗口句柄
我檢索與下面的代碼,手柄:
/* All the SDL initalisation... */
SDL_Window* window = SDL_CreateWindow("My Window", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, RESX, RESY, SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (window == NULL || renderer == NULL) {
MessageBox(NULL, L"SDL initialisation error", NULL, MB_OK);
exit(-1);
}
SDL_SysWMinfo wmInfo;
SDL_GetWindowWMInfo(window, &wmInfo);
HWND hwnd = wmInfo.info.win.window;
但在這一點上,hwnd
ADRESS是0xcccccccc
(未使用)。
我做錯了什麼?
在調用SDL_GetWindowWMInfo之前添加'SDL_VERSION(&wmInfo.version);'。 – keltar
謝謝,它工作:) – Lovy