diff options
Diffstat (limited to 'c/common.cpp')
-rw-r--r-- | c/common.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/c/common.cpp b/c/common.cpp index ba6593b..b85be49 100644 --- a/c/common.cpp +++ b/c/common.cpp @@ -61,7 +61,7 @@ Library::~Library() } /* Move message box to center of main window. */ -static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPARAM lParam) +static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPARAM lParam) noexcept { extern HWND g_hWnd; if (!g_hWnd || nCode < 0 || nCode != HCBT_ACTIVATE) @@ -87,10 +87,8 @@ static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPAR int EBMessageBox(const TCHAR* const tszText, const TCHAR* const tszCaption, const unsigned uType) { extern HWND g_hWnd; - HHOOK hHook = SetWindowsHookEx(WH_CBT, CBTProc, 0, GetCurrentThreadId()); - if (!hHook) return 0; + HHOOK hHook = throw_nil<SetWindowsHookEx>(WH_CBT, CBTProc, (HINSTANCE)NULL, GetCurrentThreadId()); int r = MessageBox(g_hWnd, tszText, tszCaption, uType); - UnhookWindowsHookEx(hHook); - if (!hHook) throw Win32Error(GetLastError()); + throw_nil<UnhookWindowsHookEx>(hHook); return r; } |