aboutsummaryrefslogtreecommitdiff
path: root/c/win32.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/win32.h')
-rw-r--r--c/win32.h54
1 files changed, 0 insertions, 54 deletions
diff --git a/c/win32.h b/c/win32.h
index c18e70f..0473f6c 100644
--- a/c/win32.h
+++ b/c/win32.h
@@ -6,8 +6,6 @@
#include <windows.h>
#include <commctrl.h>
-#include "err.h"
-
/* Convert narrow to wide string. */
std::wstring WideFromNarrow(const std::string_view src, const int cp = CP_UTF8);
@@ -23,39 +21,6 @@ int GetRelativeCursorPos(HWND hWnd, POINT* pt) noexcept;
/* Cached values from GetSystemMetrics. */
template <int I> auto Metric = GetSystemMetrics(I);
-struct WideException : public std::exception
-{
- virtual const char* what() const noexcept = 0;
- virtual const wchar_t* What() const noexcept = 0;
-};
-
-/* Exception for Windows API errors. */
-struct Win32Error : public WideException
-{
- Win32Error(DWORD code = GetLastError(), HMODULE hModule = nullptr) noexcept;
- ~Win32Error() noexcept;
- const char* what() const noexcept override;
- const wchar_t* What() const noexcept override;
- DWORD code;
-private:
- HMODULE hModule;
- char* m_szMsg = nullptr;
- wchar_t* m_wszMsg = nullptr;
-};
-
-/* Exception for extended Wininet errors. */
-struct InternetError : public WideException
-{
- InternetError(DWORD codeSystem = GetLastError());
- ~InternetError() noexcept;
- const char* what() const noexcept override;
- const wchar_t* What() const noexcept override;
- DWORD code;
-private:
- char* m_szMsg = nullptr;
- wchar_t* m_wszMsg = nullptr;
-};
-
/* Wrapper for loading and freeing dynamically linked libraries. */
struct Library
{
@@ -78,25 +43,6 @@ T* Library::GetProcAddress(const char* const szProc) noexcept
return (T*)(void*)::GetProcAddress(m_hModule, szProc);
}
-/* Check result of Windows API call, throwing error on null. */
-template <typename T>
-inline T Require(const T x)
-{
- if (!x) Err(WINDOWS, L"System error: %s");
- return x;
-}
-
-/* Check result of Windows API call, showing a warning on null. */
-template <typename T>
-inline T Prefer(const T x)
-{
- if (!x) {
- EBMessageBox(Win32Error().What(), L"System Error", MB_ICONWARNING);
- return (T)0;
- }
- return x;
-}
-
/* Return integer scaled for current DPI. */
inline int Dpi(const int i)
{