Windows: Set window icon (#5486)

master
adrido 2017-03-30 20:28:37 +02:00 committed by Loïc Blot
parent ea549bbae3
commit cc1ff26c3f
3 changed files with 34 additions and 4 deletions

View File

@ -114,7 +114,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C); porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C);
porting::setXorgWindowIcon(device); porting::setWindowIcon(device);
/* /*
This changes the minimum allowed number of vertices in a VBO. This changes the minimum allowed number of vertices in a VBO.

View File

@ -611,9 +611,9 @@ void setXorgClassHint(const video::SExposedVideoData &video_data,
#endif #endif
} }
bool setXorgWindowIcon(IrrlichtDevice *device) bool setWindowIcon(IrrlichtDevice *device)
{ {
#ifdef XORG_USED #if defined(XORG_USED)
# if RUN_IN_PLACE # if RUN_IN_PLACE
return setXorgWindowIconFromPath(device, return setXorgWindowIconFromPath(device,
path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png"); path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png");
@ -627,6 +627,36 @@ bool setXorgWindowIcon(IrrlichtDevice *device)
setXorgWindowIconFromPath(device, setXorgWindowIconFromPath(device,
path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png"); path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png");
# endif # endif
#elif defined(_WIN32)
const video::SExposedVideoData exposedData = device->getVideoDriver()->getExposedVideoData();
HWND hWnd; // Window handle
switch (device->getVideoDriver()->getDriverType()) {
case video::EDT_DIRECT3D8:
hWnd = reinterpret_cast<HWND>(exposedData.D3D8.HWnd);
break;
case video::EDT_DIRECT3D9:
hWnd = reinterpret_cast<HWND>(exposedData.D3D9.HWnd);
break;
case video::EDT_OPENGL:
hWnd = reinterpret_cast<HWND>(exposedData.OpenGLWin32.HWnd);
break;
default:
return false;
}
// Load the ICON from resource file
const HICON hicon = LoadIcon(
GetModuleHandle(NULL),
MAKEINTRESOURCE(130) // The ID of the ICON defined in winresource.rc
);
if (hicon) {
SendMessage(hWnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(hicon));
SendMessage(hWnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(hicon));
return true;
}
return false;
#else #else
return false; return false;
#endif #endif

View File

@ -367,7 +367,7 @@ inline const char *getPlatformName()
void setXorgClassHint(const video::SExposedVideoData &video_data, void setXorgClassHint(const video::SExposedVideoData &video_data,
const std::string &name); const std::string &name);
bool setXorgWindowIcon(IrrlichtDevice *device); bool setWindowIcon(IrrlichtDevice *device);
bool setXorgWindowIconFromPath(IrrlichtDevice *device, bool setXorgWindowIconFromPath(IrrlichtDevice *device,
const std::string &icon_file); const std::string &icon_file);