From 58825de892e24abff17bc842b12ec389173c0dd5 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Sun, 8 Jul 2018 23:36:28 +0900 Subject: [PATCH] [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 f116f3b953a..aec731d22d9 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) {