@@ -68,6 +68,12 @@ void jwm::WindowWin32::setTitle(const std::wstring& title) {
68
68
SetWindowTextW (_hWnd, title.c_str ());
69
69
}
70
70
71
+ void jwm::WindowWin32::setIcon (const std::wstring& iconPath) {
72
+ JWM_VERBOSE (" Set window icon '" << iconPath << " '" );
73
+ // width / height of 0 along with LR_DEFAULTSIZE tells windows to load the default icon size.
74
+ HICON hicon = (HICON)LoadImage (NULL , iconPath.c_str (), IMAGE_ICON, 0 , 0 , LR_LOADFROMFILE | LR_DEFAULTSIZE);
75
+ SendMessage (_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon);
76
+ }
71
77
void jwm::WindowWin32::setMouseCursor (MouseCursor cursor) {
72
78
JWM_VERBOSE (" Set window cursor '" << mouseCursorToStr (cursor) << " '" );
73
79
@@ -842,6 +848,14 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_WindowWin32__1nSetTitle
842
848
env->ReleaseStringChars (title, titleStr);
843
849
}
844
850
851
+ extern " C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_WindowWin32__1nSetIcon
852
+ (JNIEnv* env, jobject obj, jstring iconPath) {
853
+ jwm::WindowWin32* instance = reinterpret_cast <jwm::WindowWin32*>(jwm::classes::Native::fromJava (env, obj));
854
+ const jchar* iconPathStr = env->GetStringChars (iconPath, nullptr );
855
+ jsize length = env->GetStringLength (iconPath);
856
+ instance->setIcon (std::wstring (reinterpret_cast <const wchar_t *>(iconPathStr), length));
857
+ env->ReleaseStringChars (iconPath, iconPathStr);
858
+ }
845
859
extern " C" JNIEXPORT void JNICALL Java_org_jetbrains_jwm_WindowWin32__1nSetMouseCursor
846
860
(JNIEnv* env, jobject obj, jint cursorId) {
847
861
jwm::WindowWin32* instance = reinterpret_cast <jwm::WindowWin32*>(jwm::classes::Native::fromJava (env, obj));
0 commit comments