https://git.reactos.org/?p=reactos.git;a=commitdiff;h=58825de892e24abff17bc8...
commit 58825de892e24abff17bc842b12ec389173c0dd5 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Sun Jul 8 23:36:28 2018 +0900 Commit: Hermès BÉLUSCA - MAÏTO hermes.belusca-maito@reactos.org CommitDate: Sun Jul 8 16:36:28 2018 +0200
[EXPLORER] Fix TrackCtxMenu about NULL ppt (#666)
CORE-14772 --- base/shell/explorer/traywnd.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/base/shell/explorer/traywnd.cpp b/base/shell/explorer/traywnd.cpp index f116f3b953..aec731d22d 100644 --- a/base/shell/explorer/traywnd.cpp +++ b/base/shell/explorer/traywnd.cpp @@ -709,8 +709,9 @@ public: IN BOOL TrackUp, IN PVOID Context OPTIONAL) { - INT x = ppt->x; - INT y = ppt->y; + POINT pt; + TPMPARAMS params; + RECT rc; HRESULT hr; UINT uCommand; HMENU popup = CreatePopupMenu(); @@ -718,6 +719,17 @@ public: if (popup == NULL) return E_FAIL;
+ if (ppt) + { + pt = *ppt; + } + else + { + ::GetWindowRect(m_hWnd, &rc); + pt.x = rc.left; + pt.y = rc.top; + } + TRACE("Before Query\n"); hr = contextMenu->QueryContextMenu(popup, 0, 0, UINT_MAX, CMF_NORMAL); if (FAILED_UNEXPECTEDLY(hr)) @@ -728,7 +740,20 @@ public: }
TRACE("Before Tracking\n"); - uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, x, y, m_hWnd, NULL); + ::SetForegroundWindow(m_hWnd); + if (hwndExclude) + { + ::GetWindowRect(hwndExclude, &rc); + ZeroMemory(¶ms, sizeof(params)); + params.cbSize = sizeof(params); + params.rcExclude = rc; + uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, ¶ms); + } + else + { + uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, NULL); + } + ::PostMessage(m_hWnd, WM_NULL, 0, 0);
if (uCommand != 0) {