aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-03-19 12:16:41 +1100
committerNeil <nyamatongwe@gmail.com>2025-03-19 12:16:41 +1100
commitef7a5121743a207b5f0629614b486c431bb55af6 (patch)
treebe37a96172df6994479abc79a161d8fb355ff4d7 /win32/PlatWin.h
parent11679dfe30db5890a183bebe4e2e974c69aad116 (diff)
downloadscintilla-mirror-ef7a5121743a207b5f0629614b486c431bb55af6.tar.gz
Encapsulate WM_PAINT handling.
Diffstat (limited to 'win32/PlatWin.h')
-rw-r--r--win32/PlatWin.h12
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: