diff options
Diffstat (limited to 'backends/platform/sdl/win32/win32-window.cpp')
-rw-r--r-- | backends/platform/sdl/win32/win32-window.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/backends/platform/sdl/win32/win32-window.cpp b/backends/platform/sdl/win32/win32-window.cpp index de10be6b57..8c01da0e36 100644 --- a/backends/platform/sdl/win32/win32-window.cpp +++ b/backends/platform/sdl/win32/win32-window.cpp @@ -35,14 +35,10 @@ void SdlWindow_Win32::setupIcon() { HMODULE handle = GetModuleHandle(NULL); HICON ico = LoadIcon(handle, MAKEINTRESOURCE(1001 /* IDI_ICON */)); if (ico) { - SDL_SysWMinfo wminfo; - if (getSDLWMInformation(&wminfo)) { + HWND hwnd = getHwnd(); + if (hwnd) { // Replace the handle to the icon associated with the window class by our custom icon -#if SDL_VERSION_ATLEAST(2, 0, 0) - SetClassLongPtr(wminfo.info.win.window, GCLP_HICON, (ULONG_PTR)ico); -#else - SetClassLongPtr(wminfo.window, GCLP_HICON, (ULONG_PTR)ico); -#endif + SetClassLongPtr(hwnd, GCLP_HICON, (ULONG_PTR)ico); // Since there wasn't any default icon, we can't use the return value from SetClassLong // to check for errors (it would be 0 in both cases: error or no previous value for the @@ -56,4 +52,16 @@ void SdlWindow_Win32::setupIcon() { SdlWindow::setupIcon(); } +HWND SdlWindow_Win32::getHwnd() { + SDL_SysWMinfo wminfo; + if (getSDLWMInformation(&wminfo)) { +#if SDL_VERSION_ATLEAST(2, 0, 0) + return wminfo.info.win.window; +#else + return wminfo.window; +#endif + } + return NULL; +} + #endif |