diff options
author | Neil <nyamatongwe@gmail.com> | 2025-03-19 12:16:41 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2025-03-19 12:16:41 +1100 |
commit | ef7a5121743a207b5f0629614b486c431bb55af6 (patch) | |
tree | be37a96172df6994479abc79a161d8fb355ff4d7 /win32/PlatWin.h | |
parent | 11679dfe30db5890a183bebe4e2e974c69aad116 (diff) | |
download | scintilla-mirror-ef7a5121743a207b5f0629614b486c431bb55af6.tar.gz |
Encapsulate WM_PAINT handling.
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: |