Commit 6bcdc69e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/treeview: Check passed handle value in WM_COMMAND handler.

parent 83c9cdb7
......@@ -879,9 +879,25 @@ static void test_itemedit(void)
/* item shouldn't be selected automatically after TVM_EDITLABEL */
r = SendMessage(hTree, TVM_GETITEMSTATE, (WPARAM)hRoot, TVIS_SELECTED);
expect(0, r);
/* try to cancel with wrong edit handle */
r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)NULL);
expect(0, r);
ok(IsWindow(edit), "Expected edit control to be valid\n");
r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)edit);
expect(0, r);
ok(!IsWindow(edit), "Expected edit control to be destroyed\n");
/* try to cancel without creating edit */
r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)NULL);
expect(0, r);
/* try to cancel with wrong (not null) handle */
edit = (HWND)SendMessage(hTree, TVM_EDITLABEL, 0, (LPARAM)hRoot);
ok(IsWindow(edit), "Expected valid handle\n");
r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hTree);
expect(0, r);
ok(IsWindow(edit), "Expected edit control to be valid\n");
r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)edit);
expect(0, r);
/* remove selection after starting edit */
r = TreeView_SelectItem(hTree, hRoot);
......
......@@ -3651,8 +3651,11 @@ TREEVIEW_Command(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
break;
}
case EN_KILLFOCUS:
TREEVIEW_EndEditLabelNow(infoPtr, FALSE);
break;
/* apparently we should respect passed handle value */
if (infoPtr->hwndEdit != (HWND)lParam) return FALSE;
TREEVIEW_EndEditLabelNow(infoPtr, FALSE);
break;
default:
return SendMessageW(infoPtr->hwndNotify, WM_COMMAND, wParam, lParam);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment