comctl32/listview: Block LVM_EDITLABEL when control is unfocused and no label created

Nikolay Sivov bunglehead at gmail.com
Mon Jun 1 16:11:10 CDT 2009


>From c7f6b5f08ec78738fd358f1e065179571e9ea40a Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Mon, 1 Jun 2009 23:53:48 +0400
Subject: Block LVM_EDITLABEL when control is unfocused and no label created

---
 dlls/comctl32/listview.c       |    2 ++
 dlls/comctl32/tests/listview.c |   13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index a1aa250..09d8dae 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -5010,6 +5010,8 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
 
     if (~infoPtr->dwStyle & LVS_EDITLABELS) return 0;
     if (nItem < 0 || nItem >= infoPtr->nItemCount) return 0;
+    /* Edit could be created only on focused control and if isn't already created */
+    if (GetFocus() != infoPtr->hwndSelf && !IsWindow(infoPtr->hwndEdit)) return 0;
 
     infoPtr->nEditLabelItem = nItem;
 
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index dd5fd86..fa110cd 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2836,7 +2836,7 @@ static void test_getitemrect(void)
 
 static void test_editbox(void)
 {
-    HWND hwnd, hwndedit;
+    HWND hwnd, hwndedit, hwndedit2;
     LVITEMA item;
     DWORD r;
     static CHAR testitemA[]  = "testitem";
@@ -2878,10 +2878,19 @@ static void test_editbox(void)
 
     ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
 
+    /* send LVM_EDITLABEL on already created edit */
+    SetFocus(hwnd);
+    hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
+    ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
+    /* focus will be set to edit */
+    ok(GetFocus() == hwndedit, "Expected Edit window to be focused\n");
+    hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
+    ok(IsWindow(hwndedit2), "Expected Edit window to be created\n");
+
     /* creating label disabled when control isn't focused */
     SetFocus(0);
     hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
-    todo_wine ok(hwndedit == NULL, "Expected Edit window not to be created\n");
+    ok(hwndedit == NULL, "Expected Edit window not to be created\n");
 
     DestroyWindow(hwnd);
 }
-- 
1.5.6.5





More information about the wine-patches mailing list