Skip to content

Commit

Permalink
Add WINDOWS_ICON_ID build macro, show msgbox on windows on error
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Mar 19, 2022
1 parent a449da1 commit ddf878c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Makefile.base.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 24 additions & 1 deletion dgl/src/pugl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions distrho/src/DistrhoPluginJACK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ddf878c

Please sign in to comment.