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

This commit is contained in:
Nikolay Sivov 2009-08-07 00:13:25 +04:00 committed by Alexandre Julliard
parent 83c9cdb797
commit 6bcdc69ec0
2 changed files with 21 additions and 2 deletions

View File

@ -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);

View File

@ -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);