From 2f7b69d6d4cf18ca9ca04d9a44aaa6871ce51160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 7 Sep 2022 00:40:26 +0200 Subject: Improve error handling. --- c/drag.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'c/drag.cpp') diff --git a/c/drag.cpp b/c/drag.cpp index b92429a..1622653 100644 --- a/c/drag.cpp +++ b/c/drag.cpp @@ -24,7 +24,8 @@ bool Dragger::IsDown() const bool Dragger::HandleLButtonDown() { POINT pt; - Require(GetRelativeCursorPos(parent.hWnd, &pt)); + if (!GetRelativeCursorPos(parent.hWnd, &pt)) + throw Err(WINDOWS, L"Mouse cursor position could not be retrieved: %s"); if (!InDragArea(pt.x, pt.y)) return false; if (IsDouble(GetMessageTime(), pt)) { @@ -39,7 +40,8 @@ bool Dragger::HandleLButtonDown() bool Dragger::HandleSetCursor() { POINT pt; - Require(GetRelativeCursorPos(parent.hWnd, &pt)); + if (!GetRelativeCursorPos(parent.hWnd, &pt)) + throw Err(WINDOWS, L"Mouse cursor position could not be retrieved: %s"); extern HCURSOR g_hcSizeNs; bool r = true; @@ -60,7 +62,8 @@ bool Dragger::HandleSetCursor() bool DlvDragger::InDragArea(const int x, const int y) const { RECT rrDlv; - Require(GetRelativeRect(parent.dlv.hWnd, &rrDlv)); + if (!GetRelativeRect(parent.dlv.hWnd, &rrDlv)) + throw Err(WINDOWS, L"Data list view rectangle could not be retrieved: %s"); const int pad = EBIsThemeActive()? Dpi(6): 0; const int extra = EBIsThemeActive()? 0: Dpi(2); @@ -72,7 +75,8 @@ bool DlvDragger::InDragArea(const int x, const int y) const void DlvDragger::Drag(const int, const int y) const { RECT rrDlv; - Require(GetRelativeRect(parent.dlv.hWnd, &rrDlv)); + if (!GetRelativeRect(parent.dlv.hWnd, &rrDlv)) + throw Err(WINDOWS, L"Data list view rectangle could not be retrieved: %s"); if (y < Dpi(50) || y > rrDlv.bottom-Dpi(20)) return; -- cgit v1.2.3