comctl32/listview: Edit box should be destroyed on invalid index too (LVM_EDITLABEL).
This commit is contained in:
parent
e90102d5ff
commit
c111500458
|
@ -5060,9 +5060,6 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
|
|||
TRACE("(nItem=%d, isW=%d)\n", nItem, isW);
|
||||
|
||||
if (~infoPtr->dwStyle & LVS_EDITLABELS) return 0;
|
||||
if (nItem < 0 || nItem >= infoPtr->nItemCount) return 0;
|
||||
|
||||
infoPtr->nEditLabelItem = nItem;
|
||||
|
||||
/* Is the EditBox still there, if so remove it */
|
||||
if(infoPtr->hwndEdit != 0)
|
||||
|
@ -5071,6 +5068,10 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
|
|||
infoPtr->hwndEdit = 0;
|
||||
}
|
||||
|
||||
if (nItem < 0 || nItem >= infoPtr->nItemCount) return 0;
|
||||
|
||||
infoPtr->nEditLabelItem = nItem;
|
||||
|
||||
LISTVIEW_SetSelection(infoPtr, nItem);
|
||||
LISTVIEW_SetItemFocus(infoPtr, nItem);
|
||||
LISTVIEW_InvalidateItem(infoPtr, nItem);
|
||||
|
|
|
@ -2957,6 +2957,38 @@ static void test_editbox(void)
|
|||
expect(lstrlen(item.pszText), r);
|
||||
ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
|
||||
|
||||
/* LVM_EDITLABEL with -1 destroys current edit */
|
||||
hwndedit = (HWND)SendMessage(hwnd, LVM_GETEDITCONTROL, 0, 0);
|
||||
ok(hwndedit == NULL, "Expected Edit window not to be created\n");
|
||||
/* no edit present */
|
||||
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -1, 0);
|
||||
ok(hwndedit == NULL, "Expected Edit window not to be created\n");
|
||||
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
|
||||
ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
|
||||
/* edit present */
|
||||
ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
|
||||
hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -1, 0);
|
||||
ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
|
||||
ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
|
||||
ok(GetFocus() == hwnd, "Expected List to be focused\n");
|
||||
/* check another negative value */
|
||||
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
|
||||
ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
|
||||
ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
|
||||
hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -2, 0);
|
||||
ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
|
||||
ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
|
||||
ok(GetFocus() == hwnd, "Expected List to be focused\n");
|
||||
/* and value greater then max item index */
|
||||
hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
|
||||
ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
|
||||
ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
|
||||
r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
|
||||
hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, r, 0);
|
||||
ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
|
||||
ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
|
||||
ok(GetFocus() == hwnd, "Expected List to be focused\n");
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue