相关疑难解决方法(0)

获取SDL 2应用程序的窗口句柄

我想获得SDL2窗口的句柄,并与WinApi一起使用。

我使用以下代码检索该句柄:

/* 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;
Run Code Online (Sandbox Code Playgroud)

但是在这一点上,hwnd地址0xcccccccc(未使用)。

我做错什么了吗?

c winapi sdl sdl-2

2
推荐指数
1
解决办法
6077
查看次数

标签 统计

c ×1

sdl ×1

sdl-2 ×1

winapi ×1