Jason Edmeades : comctl32: Listview fails to add a column if mask=0.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Aug 17 06:30:29 CDT 2007


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

Author: Jason Edmeades <jason.edmeades at googlemail.com>
Date:   Thu Aug 16 23:45:41 2007 +0100

comctl32: Listview fails to add a column if mask=0.

---

 dlls/comctl32/listview.c       |   11 ++++++++++-
 dlls/comctl32/tests/listview.c |   23 +++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 7602217..ab60d23 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -6659,7 +6659,16 @@ static INT LISTVIEW_InsertColumnT(LISTVIEW_INFO *infoPtr, INT nColumn,
     
     ZeroMemory(&hdi, sizeof(HDITEMW));
     column_fill_hditem(infoPtr, &hdi, nColumn, lpColumn, isW);
-    
+
+    /*
+     * A mask not including LVCF_WIDTH turns into a mask of width, width 10
+     * (can be seen in SPY) otherwise column never gets added.
+     */
+    if (!(lpColumn->mask & LVCF_WIDTH)) {
+        hdi.mask |= HDI_WIDTH;
+        hdi.cxy = 10;
+    }
+
     /*
      * when the iSubItem is available Windows copies it to the header lParam. It seems
      * to happen only in LVM_INSERTCOLUMN - not in LVM_SETCOLUMN
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index a64d4d3..9138442 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -676,6 +676,28 @@ static void test_items(void)
     DestroyWindow(hwnd);
 }
 
+static void test_columns(void)
+{
+    HWND hwnd;
+    LVCOLUMN column;
+    DWORD rc;
+
+    hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
+                10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
+    ok(hwnd != NULL, "failed to create listview window\n");
+
+    /* Add a column with no mask */
+    memset(&column, 0xaa, sizeof(column));
+    column.mask = 0;
+    rc = ListView_InsertColumn(hwnd, 0, &column);
+    ok(rc==0, "Inserting column with no mask failed with %d\n", rc);
+
+    /* Check its width */
+    rc = ListView_GetColumnWidth(hwnd, 0);
+    ok(rc==10, "Inserting column with no mask failed to set width to 10 with %d\n", rc);
+
+    DestroyWindow(hwnd);
+}
 /* test setting imagelist between WM_NCCREATE and WM_CREATE */
 static WNDPROC listviewWndProc;
 static HIMAGELIST test_create_imagelist;
@@ -1041,4 +1063,5 @@ START_TEST(listview)
     test_color();
     test_item_count();
     test_item_position();
+    test_columns();
 }




More information about the wine-cvs mailing list