https://git.reactos.org/?p=reactos.git;a=commitdiff;h=163f3407c8fa93ce06773…
commit 163f3407c8fa93ce06773fdf9fc53064506bd05e
Author: Whindmar Saksit <whindsaks(a)proton.me>
AuthorDate: Sat Aug 31 18:30:45 2024 +0200
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Aug 31 18:30:45 2024 +0200
[RAPPS] Show listview context menu when the keyboard menu button/Shift+F10 is pressed
(#5620)
---
base/applications/rapps/appview.cpp | 33 ++++++++++++++++++++++++---------
base/applications/rapps/include/misc.h | 2 +-
base/applications/rapps/misc.cpp | 9 ++++++---
3 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/base/applications/rapps/appview.cpp b/base/applications/rapps/appview.cpp
index e2af2ab6c5c..a173d9530ac 100644
--- a/base/applications/rapps/appview.cpp
+++ b/base/applications/rapps/appview.cpp
@@ -1569,15 +1569,6 @@ CApplicationView::ProcessWindowMessage(
}
}
break;
-
- case NM_RCLICK:
- {
- if (((LPNMLISTVIEW)lParam)->iItem != -1)
- {
- ShowPopupMenuEx(m_hWnd, m_hWnd, 0, ID_INSTALL);
- }
- }
- break;
}
}
else if (pNotifyHeader->hwndFrom == m_Toolbar->GetWindow())
@@ -1613,6 +1604,30 @@ CApplicationView::ProcessWindowMessage(
OnCommand(wParam, lParam);
}
break;
+
+ case WM_CONTEXTMENU:
+ {
+ bool kbd = -1 == (int)(INT_PTR)lParam;
+ if ((HWND)wParam == m_ListView->m_hWnd)
+ {
+ int item = m_ListView->GetNextItem(-1, LVNI_FOCUSED | LVNI_SELECTED);
+ if (item != -1)
+ {
+ POINT *ppt = NULL, pt;
+ if (kbd)
+ {
+ RECT r;
+ ListView_GetItemRect((HWND)wParam, item, &r, LVIR_LABEL);
+ pt.x = r.left + (r.right - r.left) / 2;
+ pt.y = r.top + (r.bottom - r.top) / 2;
+ ::ClientToScreen((HWND)wParam, ppt = &pt);
+ }
+ ShowPopupMenuEx(m_hWnd, m_hWnd, 0, ID_INSTALL, ppt);
+ return TRUE;
+ }
+ }
+ }
+ break;
}
return FALSE;
}
diff --git a/base/applications/rapps/include/misc.h
b/base/applications/rapps/include/misc.h
index b43585d748a..91ede797f08 100644
--- a/base/applications/rapps/include/misc.h
+++ b/base/applications/rapps/include/misc.h
@@ -29,7 +29,7 @@ ErrorFromHResult(HRESULT hr)
VOID
CopyTextToClipboard(LPCWSTR lpszText);
VOID
-ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem);
+ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point =
NULL);
BOOL
StartProcess(const CStringW &Path, BOOL Wait);
BOOL
diff --git a/base/applications/rapps/misc.cpp b/base/applications/rapps/misc.cpp
index f2b15d5c645..400f0b588e6 100644
--- a/base/applications/rapps/misc.cpp
+++ b/base/applications/rapps/misc.cpp
@@ -40,7 +40,7 @@ CopyTextToClipboard(LPCWSTR lpszText)
}
VOID
-ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem)
+ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point)
{
HMENU hMenu = NULL;
HMENU hPopupMenu;
@@ -68,10 +68,13 @@ ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT
DefaultItem)
SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
}
- GetCursorPos(&pt);
+ if (!Point)
+ {
+ GetCursorPos(Point = &pt);
+ }
SetForegroundWindow(hwnd);
- TrackPopupMenu(hPopupMenu, 0, pt.x, pt.y, 0, hwndOwner, NULL);
+ TrackPopupMenu(hPopupMenu, 0, Point->x, Point->y, 0, hwndOwner, NULL);
if (hMenu)
{