summaryrefslogtreecommitdiff
path: root/src/porting.cpp
diff options
context:
space:
mode:
authoradrido <robots_only_adrido@gmx.com>2017-03-30 20:28:37 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-03-30 20:28:37 +0200
commitcc1ff26c3f078cd11f309a7cb24b7921baef89b7 (patch)
tree69867d2761488addd520f80206b09cbc0380ac21 /src/porting.cpp
parentea549bbae3650d246db7b70a2b07485a4b404409 (diff)
downloadminetest-cc1ff26c3f078cd11f309a7cb24b7921baef89b7.tar.gz
minetest-cc1ff26c3f078cd11f309a7cb24b7921baef89b7.tar.bz2
minetest-cc1ff26c3f078cd11f309a7cb24b7921baef89b7.zip
Windows: Set window icon (#5486)
Diffstat (limited to 'src/porting.cpp')
-rw-r--r--src/porting.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/porting.cpp b/src/porting.cpp
index 023f0cca7..4786a2a39 100644
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -611,9 +611,9 @@ void setXorgClassHint(const video::SExposedVideoData &video_data,
#endif
}
-bool setXorgWindowIcon(IrrlichtDevice *device)
+bool setWindowIcon(IrrlichtDevice *device)
{
-#ifdef XORG_USED
+#if defined(XORG_USED)
# if RUN_IN_PLACE
return setXorgWindowIconFromPath(device,
path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png");
@@ -627,6 +627,36 @@ bool setXorgWindowIcon(IrrlichtDevice *device)
setXorgWindowIconFromPath(device,
path_share + "/misc/" PROJECT_NAME "-xorg-icon-128.png");
# 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
return false;
#endif