MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / setWindowIcon

Function setWindowIcon

src/Engine/CrossPlatform.cpp:941–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

939}
940
941void setWindowIcon(int winResource, const std::string &unixPath)
942{
943#ifdef _WIN32
944 HINSTANCE handle = GetModuleHandle(NULL);
945 HICON icon = LoadIcon(handle, MAKEINTRESOURCE(winResource));
946
947 SDL_SysWMinfo wminfo;
948 SDL_VERSION(&wminfo.version)
949 if (SDL_GetWMInfo(&wminfo))
950 {
951 HWND hwnd = wminfo.window;
952 SetClassLongPtr(hwnd, GCLP_HICON, (LONG_PTR)icon);
953 }
954#else
955 // SDL only takes UTF-8 filenames
956 // so here's an ugly hack to match this ugly reasoning
957 std::string utf8 = Language::wstrToUtf8(Language::fsToWstr(CrossPlatform::getDataFile(unixPath)));
958 SDL_Surface *icon = IMG_Load(utf8.c_str());
959 if (icon != 0)
960 {
961 SDL_WM_SetIcon(icon, NULL);
962 SDL_FreeSurface(icon);
963 }
964#endif
965}
966
967}
968}

Callers 1

GameMethod · 0.85

Calls 1

getDataFileFunction · 0.85

Tested by

no test coverage detected