https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c96ba1aff2a681184f9ae…
commit c96ba1aff2a681184f9aefd66327224d59e7d08a
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Thu Aug 8 21:01:19 2019 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Thu Aug 15 11:28:31 2019 +0200
[SHELL32] CDefView: Improve the context menu positioning
Previously we would always show a menu on the focused item, but
this should only be done when it is also selected.
---
dll/win32/shell32/CDefView.cpp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/dll/win32/shell32/CDefView.cpp b/dll/win32/shell32/CDefView.cpp
index df076f5263a..acaa2e66383 100644
--- a/dll/win32/shell32/CDefView.cpp
+++ b/dll/win32/shell32/CDefView.cpp
@@ -1443,15 +1443,19 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM
lParam, BOOL &b
/* There is no position requested, so try to find one */
if (lParam == ~0)
{
- int lvIndex;
+ HWND hFocus = ::GetFocus();
+ int lvIndex = -1;
POINT pt;
- /* Do we have a focused item, */
- if ((lvIndex = m_ListView.GetNextItem(-1, LVIS_FOCUSED)) < 0)
+ if (hFocus == m_ListView.m_hWnd || m_ListView.IsChild(hFocus))
{
- /* or a selected item? */
- lvIndex = m_ListView.GetNextItem(-1, LVIS_SELECTED);
+ /* Is there an item focused and selected? */
+ lvIndex = m_ListView.GetNextItem(-1, LVIS_SELECTED|LVIS_FOCUSED);
+ /* If not, find the first selected item */
+ if (lvIndex < 0)
+ lvIndex = m_ListView.GetNextItem(-1, LVIS_SELECTED);
}
+
/* We got something */
if (lvIndex > -1)
{