diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-20 21:27:30 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-20 21:27:30 +0200 |
commit | 561ee240477e348efcd3670a5481ccb538d6724b (patch) | |
tree | 0bfee883963a390c657e627a2184068826168d6f /c/common.h | |
parent | 3f842c733568aa9068aa83fad52540eb98f334b1 (diff) | |
download | EpisodeBrowser-561ee240477e348efcd3670a5481ccb538d6724b.tar.gz |
Simplify UpdateLayout.
Diffstat (limited to 'c/common.h')
-rw-r--r-- | c/common.h | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -56,7 +56,7 @@ std::optional<T> maybe_make(U... xs) /* Call Windows API function, throwing error on NULL. */ template <typename T> -inline T require(T x) +inline T require(const T x) { if (!x) throw Win32Error(); return x; @@ -64,7 +64,7 @@ inline T require(T x) /* Call Windows API function, showing a warning on NULL. */ template <typename T> -inline T prefer(T x) +inline T prefer(const T x) { if (!x) { EBMessageBox(Win32Error().what<TCHAR>(), @@ -88,4 +88,25 @@ inline int Cmp(const int a, const int b) return -1; } +/* Get window rectangle relative to parent. */ +inline BOOL GetRelativeRect(const HWND hWnd, RECT* const pRr) +{ + if (!GetClientRect(hWnd, pRr)) return 0; + return MapWindowPoints(hWnd, GetParent(hWnd), (POINT*)pRr, 2); +} + +inline BOOL SetWindowRect(const HWND hWnd, + const long left, const long top, const long right, const long bottom) +{ + return MoveWindow(hWnd, + left, top, + right-left, bottom-top, + TRUE); +} + +inline BOOL SetWindowRect(const HWND hWnd, const RECT r) +{ + return SetWindowRect(hWnd, r.left, r.top, r.right, r.bottom); +} + #endif |