aboutsummaryrefslogtreecommitdiff
path: root/c/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/common.cpp')
-rw-r--r--c/common.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/c/common.cpp b/c/common.cpp
index 494c382..a91836d 100644
--- a/c/common.cpp
+++ b/c/common.cpp
@@ -2,6 +2,8 @@
#include "common.h"
+/* Win32Error: Exception for Windows API errors. */
+
Win32Error::Win32Error(const DWORD dwErr) : m_dwErr(dwErr) {}
Win32Error::~Win32Error()
@@ -46,6 +48,8 @@ const TCHAR* Win32Error::twhat() const noexcept
#undef M
}
+/* Library: Wrapper for loading and freeing dynamically linked libraries. */
+
Library::Library(const TCHAR* const tszLibrary)
{
m_hModule = LoadLibrary(tszLibrary);
@@ -66,21 +70,22 @@ static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPAR
return CallNextHookEx(0, nCode, wParam, lParam);
HWND hWnd = (HWND)wParam;
- if (long lStyle = GetWindowLong(hWnd, GWL_STYLE))
- if (lStyle & WS_POPUP) {
- RECT rcMain, rcMsg;
- GetWindowRect(g_hWnd, &rcMain);
- GetWindowRect(hWnd, &rcMsg);
- SetWindowPos(hWnd, NULL,
- rcMain.left+(rcMain.right-rcMain.left)/2-(rcMsg.right-rcMsg.left)/2,
- rcMain.top+(rcMain.bottom-rcMain.top)/2-(rcMsg.bottom-rcMsg.top)/2,
- -1, -1,
- SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
- }
+ long lStyle = GetWindowLong(hWnd, GWL_STYLE);
+ if (!(lStyle & WS_POPUP)) return 0;
+
+ RECT rcMain, rcMsg;
+ GetWindowRect(g_hWnd, &rcMain);
+ GetWindowRect(hWnd, &rcMsg);
+ SetWindowPos(hWnd, NULL,
+ rcMain.left+(rcMain.right-rcMain.left)/2-(rcMsg.right-rcMsg.left)/2,
+ rcMain.top+(rcMain.bottom-rcMain.top)/2-(rcMsg.bottom-rcMsg.top)/2,
+ -1, -1,
+ SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
return 0;
}
+/* Show message box owned by and centered in the main window. */
int EBMessageBox(const TCHAR* const tszText, const TCHAR* const tszCaption, const unsigned uType)
{
extern HWND g_hWnd;