ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

win32-window.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 // Disable symbol overrides so that we can use system headers.
00024 #define FORBIDDEN_SYMBOL_ALLOW_ALL
00025 
00026 #ifdef WIN32
00027 
00028 #include "backends/platform/sdl/win32/win32-window.h"
00029 
00030 #define WIN32_LEAN_AND_MEAN
00031 #include <windows.h>
00032 
00033 void SdlWindow_Win32::setupIcon() {
00034     HMODULE handle = GetModuleHandle(NULL);
00035     HICON   ico    = LoadIcon(handle, MAKEINTRESOURCE(1001 /* IDI_ICON */));
00036     if (ico) {
00037         HWND hwnd = getHwnd();
00038         if (hwnd) {
00039             // Replace the handle to the icon associated with the window class by our custom icon
00040             SetClassLongPtr(hwnd, GCLP_HICON, (ULONG_PTR)ico);
00041 
00042             // Since there wasn't any default icon, we can't use the return value from SetClassLong
00043             // to check for errors (it would be 0 in both cases: error or no previous value for the
00044             // icon handle). Instead we check for the last-error code value.
00045             if (GetLastError() == ERROR_SUCCESS)
00046                 return;
00047         }
00048     }
00049 
00050     // If no icon has been set, fallback to default path
00051     SdlWindow::setupIcon();
00052 }
00053 
00054 HWND SdlWindow_Win32::getHwnd() {
00055     SDL_SysWMinfo wminfo;
00056     if (getSDLWMInformation(&wminfo)) {
00057 #if SDL_VERSION_ATLEAST(2, 0, 0)
00058         return wminfo.info.win.window;
00059 #else
00060         return wminfo.window;
00061 #endif
00062     }
00063     return NULL;
00064 }
00065 
00066 #endif


Generated on Sat Mar 16 2019 05:02:02 for ResidualVM by doxygen 1.7.1
curved edge   curved edge