diff options
Diffstat (limited to 'win32/PlatWin.h')
-rw-r--r-- | win32/PlatWin.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/win32/PlatWin.h b/win32/PlatWin.h index 6c51ec8ad..de99a5fc0 100644 --- a/win32/PlatWin.h +++ b/win32/PlatWin.h @@ -60,6 +60,18 @@ int SystemMetricsForDpi(int nIndex, UINT dpi) noexcept; HCURSOR LoadReverseArrowCursor(UINT dpi) noexcept; +// Encapsulate WM_PAINT handling so that EndPaint is always called even with unexpected returns or exceptions. +struct Painter { + HWND hWnd{}; + PAINTSTRUCT ps{}; + explicit Painter(HWND hWnd_) noexcept : hWnd(hWnd_) { + ::BeginPaint(hWnd, &ps); + } + ~Painter() { + ::EndPaint(hWnd, &ps); + } +}; + class MouseWheelDelta { int wheelDelta = 0; public: |