commit ddf878c13a08dd212e3dcc3ce1bd708ea2373dbb
parent a449da1881e3d5bffeb45be476ac34302870708d
Author: falkTX <falktx@falktx.com>
Date: Sat, 19 Mar 2022 17:52:13 +0000
Add WINDOWS_ICON_ID build macro, show msgbox on windows on error
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/Makefile.base.mk b/Makefile.base.mk
@@ -444,6 +444,10 @@ ifeq ($(FILE_BROWSER_DISABLED),true)
BUILD_CXX_FLAGS += -DDGL_FILE_BROWSER_DISABLED
endif
+ifneq ($(WINDOWS_ICON_ID),)
+BUILD_CXX_FLAGS += -DDGL_WINDOWS_ICON_ID=$(WINDOWS_ICON_ID)
+endif
+
ifeq ($(USE_OPENGL3),true)
BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3
endif
diff --git a/dgl/src/pugl.cpp b/dgl/src/pugl.cpp
@@ -567,7 +567,30 @@ void puglWin32ShowCentered(PuglView* const view)
}
else
{
- ShowWindow(impl->hwnd, SW_SHOWNORMAL);
+#ifdef DGL_WINDOWS_ICON_ID
+ WNDCLASSEX wClass;
+ std::memset(&wClass, 0, sizeof(wClass));
+
+ const HINSTANCE hInstance = GetModuleHandle(nullptr);
+
+ if (GetClassInfoEx(hInstance, view->world->className, &wClass))
+ wClass.hIcon = LoadIcon(nullptr, MAKEINTRESOURCE(DGL_WINDOWS_ICON_ID));
+
+ SetClassLongPtr(impl->hwnd, GCLP_HICON, (LONG_PTR) LoadIcon(hInstance, MAKEINTRESOURCE(DGL_WINDOWS_ICON_ID)));
+#endif
+
+ MONITORINFO mInfo;
+ std::memset(&mInfo, 0, sizeof(mInfo));
+ mInfo.cbSize = sizeof(mInfo);
+
+ if (GetMonitorInfo(MonitorFromWindow(impl->hwnd, MONITOR_DEFAULTTOPRIMARY), &mInfo))
+ SetWindowPos(impl->hwnd,
+ HWND_TOP,
+ mInfo.rcWork.left + (mInfo.rcWork.right - view->frame.width) / 2,
+ mInfo.rcWork.top + (mInfo.rcWork.bottom - view->frame.height) / 2,
+ 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE);
+ else
+ ShowWindow(impl->hwnd, SW_NORMAL);
}
SetFocus(impl->hwnd);
diff --git a/distrho/src/DistrhoPluginJACK.cpp b/distrho/src/DistrhoPluginJACK.cpp
@@ -944,11 +944,15 @@ int main(int argc, char* argv[])
if (errorString.isNotEmpty())
{
errorString[errorString.length()-2] = '.';
- d_stderr("Failed to create jack client, reason was:\n%s", errorString.buffer());
+ d_stderr("Failed to create the JACK client, reason was:\n%s", errorString.buffer());
}
else
- d_stderr("Failed to create jack client, cannot continue!");
+ d_stderr("Failed to create the JACK client, cannot continue!");
+ #if defined(DISTRHO_OS_WINDOWS) && DISTRHO_PLUGIN_HAS_UI
+ const String win32error = "Failed to create JACK client, reason was:\n" + errorString;
+ MessageBoxA(nullptr, win32error.buffer(), "", MB_ICONERROR);
+ #endif
return 1;
}