commit efe5412b1e3854dfe3fdc83bea6df453fcfde5f8
parent 98d0fd6e11d50568d16a67b207ac30aa8d49acf2
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sun, 21 Aug 2016 14:49:11 -0700
listview: avoid displaying the context menu on Shift+10 outside of the control
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/listview.cpp b/src/listview.cpp
@@ -321,11 +321,15 @@ bool ListView::onContextMenu(HWND dialog, int x, int y)
index = currentIndex();
// find the location of the current item or of the first item
- POINT point{};
- ListView_GetItemPosition(handle(), translate(max(0, index)), &point);
- ClientToScreen(handle(), &point);
- x = point.x;
- y = point.y;
+ POINT itemPos{};
+ ListView_GetItemPosition(handle(), translate(max(0, index)), &itemPos);
+ ClientToScreen(handle(), &itemPos);
+
+ RECT controlRect;
+ GetWindowRect(handle(), &controlRect);
+
+ x = max(controlRect.left, min(itemPos.x, controlRect.right));
+ y = max(controlRect.top, min(itemPos.y, controlRect.bottom));
}
#endif