diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-19 14:49:24 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-19 14:49:24 +0200 |
commit | 2ffbd7fcc178e68e7132d2f8f649d131c5a5d3af (patch) | |
tree | 7a3983e4ccd4ab14413fe9209a8142727cb83a23 /c/common.cpp | |
parent | aac409bdd73fd96d256f87285a7c9b959d2117b3 (diff) | |
download | EpisodeBrowser-2ffbd7fcc178e68e7132d2f8f649d131c5a5d3af.tar.gz |
Add comments.
Diffstat (limited to 'c/common.cpp')
-rw-r--r-- | c/common.cpp | 27 |
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; |