Commit c1115004 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Edit box should be destroyed on invalid index too (LVM_EDITLABEL).

parent e90102d5
...@@ -5060,9 +5060,6 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW) ...@@ -5060,9 +5060,6 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
TRACE("(nItem=%d, isW=%d)\n", nItem, isW); TRACE("(nItem=%d, isW=%d)\n", nItem, isW);
if (~infoPtr->dwStyle & LVS_EDITLABELS) return 0; 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 */ /* Is the EditBox still there, if so remove it */
if(infoPtr->hwndEdit != 0) if(infoPtr->hwndEdit != 0)
...@@ -5071,6 +5068,10 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW) ...@@ -5071,6 +5068,10 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
infoPtr->hwndEdit = 0; infoPtr->hwndEdit = 0;
} }
if (nItem < 0 || nItem >= infoPtr->nItemCount) return 0;
infoPtr->nEditLabelItem = nItem;
LISTVIEW_SetSelection(infoPtr, nItem); LISTVIEW_SetSelection(infoPtr, nItem);
LISTVIEW_SetItemFocus(infoPtr, nItem); LISTVIEW_SetItemFocus(infoPtr, nItem);
LISTVIEW_InvalidateItem(infoPtr, nItem); LISTVIEW_InvalidateItem(infoPtr, nItem);
......
...@@ -2957,6 +2957,38 @@ static void test_editbox(void) ...@@ -2957,6 +2957,38 @@ static void test_editbox(void)
expect(lstrlen(item.pszText), r); expect(lstrlen(item.pszText), r);
ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n"); 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); DestroyWindow(hwnd);
} }
......
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