diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-22 01:05:05 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-22 01:05:05 +0200 |
commit | ba0750ff48bcf97ef99602fe27322fa706a93b6b (patch) | |
tree | 0a6e0110e1940610266d280e2c857195819ffa1a /c/win.cpp | |
parent | 28b87e4d9c60b49d46b03a19b7b83e23e222087a (diff) | |
download | EpisodeBrowser-ba0750ff48bcf97ef99602fe27322fa706a93b6b.tar.gz |
Add Buf class.
Diffstat (limited to 'c/win.cpp')
-rw-r--r-- | c/win.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
@@ -1,4 +1,5 @@ #include <utility> +#include <string> #include <SWI-Prolog.h> #include <windows.h> @@ -7,28 +8,6 @@ #include "win.h" #include "wcharptr.h" -void ShowException(const wchar_t* const fmt, const wchar_t* const title, const UINT uType) noexcept -{ - const wchar_t* what = L"an exception"; - WcharPtr why; - - try { - std::rethrow_exception(std::current_exception()); - } catch (const term_t& t) { - what = L"a Prolog exception"; - try { why = PlString(t); } catch (...) {} - } catch (const Win32Error& e) { - what = L"a Windows error"; - try { why = WcharPtr::Copy(e.What()); } catch (...) {} - } catch (const std::exception& e) { - try { why = WcharPtr::FromNarrow(e.what()); } catch (...) {} - } catch (...) {} - - wchar_t msg[512]; - Swprintf(msg, fmt, what, static_cast<wchar_t*>(why)); - EBMessageBox(msg, title, uType); -} - void WithNextWindow(void (*proc)(HWND)) { /* WithNextWindow uses a CBT hook to call an arbitrary @@ -103,6 +82,28 @@ int EBMessageBox(const std::wstring_view text, const std::wstring_view caption, return MessageBox(g_hWnd, text.data(), caption.data(), uType); } +void ShowException(const wchar_t* const fmt, const wchar_t* const title, const UINT uType) noexcept +{ + const wchar_t* what = L"an exception"; + WcharPtr why; + + try { + std::rethrow_exception(std::current_exception()); + } catch (const term_t& t) { + what = L"a Prolog exception"; + try { why = PlString(t); } catch (...) {} + } catch (const Win32Error& e) { + what = L"a Windows error"; + try { why = WcharPtr::Copy(e.What()); } catch (...) {} + } catch (const std::exception& e) { + try { why = WcharPtr::FromNarrow(e.what()); } catch (...) {} + } catch (...) {} + + std::wstring msg(wcslen(fmt)+wcslen(what)+wcslen(why), 0); + Swprintf(msg, fmt, what, static_cast<wchar_t*>(why)); + EBMessageBox(msg, title, uType); +} + int GetRelativeCursorPos(const HWND hWnd, POINT* const pt) noexcept { RECT rc; |