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

Alexandre Julliard julliard at winehq.org
Mon Jun 8 09:44:47 CDT 2009


Module: wine
Branch: master
Commit: c1115004582371e015a6cbe6ea2cf8bea50a223c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c1115004582371e015a6cbe6ea2cf8bea50a223c

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Sat Jun  6 01:32:02 2009 +0400

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

---

 dlls/comctl32/listview.c       |    7 ++++---
 dlls/comctl32/tests/listview.c |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 8d4f6f3..d302e38 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -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);
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 9ecbeed..933aa29 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -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);
 }
 




More information about the wine-cvs mailing list