[EXPLORER] Fix TrackCtxMenu about NULL ppt (#666)

CORE-14772
This commit is contained in:
Katayama Hirofumi MZ 2018-07-08 23:36:28 +09:00 committed by Hermès BÉLUSCA - MAÏTO
parent a882ec7a02
commit 58825de892

View file

@ -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(&params, sizeof(params));
params.cbSize = sizeof(params);
params.rcExclude = rc;
uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, &params);
}
else
{
uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, pt.x, pt.y, m_hWnd, NULL);
}
::PostMessage(m_hWnd, WM_NULL, 0, 0);
if (uCommand != 0)
{