mirror of https://github.com/encounter/SDL.git
Fixed bug 3486 - Can't get HINSTANCE of my window
realitix SDL2 allows to create widow and to get information through SDL_SysWMinfo. But it misses something, with Vulkan, you need the HWND and HINSTANCE of the window for Win32 system. Sadly, SDL2 provides only HWND but not HINSTANCE. In some context, it can be difficult to get the HINSTANCE, indeed, I'm using pySDL2 (Python) and I can only access properties that SDL2 gives me. I have to use a dirty trick like that to get the HINSTANCE: (https://raw.githubusercontent.com/bglgwyng/pyVulkan/master/examples/win32misc.py)
This commit is contained in:
parent
2a5fab63ee
commit
4a089ca1c8
|
@ -201,6 +201,7 @@ struct SDL_SysWMinfo
|
|||
{
|
||||
HWND window; /**< The window handle */
|
||||
HDC hdc; /**< The window device context */
|
||||
HINSTANCE hinstance; /**< The instance handle */
|
||||
} win;
|
||||
#endif
|
||||
#if defined(SDL_VIDEO_DRIVER_WINRT)
|
||||
|
|
|
@ -127,6 +127,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
data->window = window;
|
||||
data->hwnd = hwnd;
|
||||
data->hdc = GetDC(hwnd);
|
||||
data->hinstance = (HINSTANCE) GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
data->created = created;
|
||||
data->mouse_button_flags = 0;
|
||||
data->videodata = videodata;
|
||||
|
@ -706,6 +707,10 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
|||
info->info.win.hdc = data->hdc;
|
||||
}
|
||||
|
||||
if (versionnum >= SDL_VERSIONNUM(2, 0, 5)) {
|
||||
info->info.win.hinstance = data->hinstance;
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
|
|
|
@ -33,6 +33,7 @@ typedef struct
|
|||
HWND hwnd;
|
||||
HDC hdc;
|
||||
HDC mdc;
|
||||
HINSTANCE hinstance;
|
||||
HBITMAP hbm;
|
||||
WNDPROC wndproc;
|
||||
SDL_bool created;
|
||||
|
|
Loading…
Reference in New Issue