[5/8] comctl32/listview: Add partial support for cxMin width field

Nikolay Sivov bunglehead at gmail.com
Sun Sep 6 15:00:33 CDT 2009


Field cxMin used for resizing after doubleclicked header divider event and
while handling LVM_SETCOLUMNWIDTH as well.

It also should be used in conjunction with LVS_EX_COLUMNSNAPPOINTS (and LVS_EX_AUTOSIZECOLUMNS too maybe)
but I didn't figure out how yet.

Changelog:
    - Add partial support for cxMin width field

>From 6844d1b21b1f3628b0045fc794161dcff51598b8 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun, 6 Sep 2009 13:54:28 +0400
Subject: Add partial support for cxMin width field:
 - store and retrieve it;
 - respect min width while autosizing column.

---
 dlls/comctl32/listview.c |   14 +++++++++++---
 include/commctrl.h       |    1 +
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index def3d1f..1c0f58b 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -176,7 +176,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(listview);
 typedef struct tagCOLUMN_INFO
 {
   RECT rcHeader;	/* tracks the header's rectangle */
-  int fmt;		/* same as LVCOLUMN.fmt */
+  INT fmt;		/* same as LVCOLUMN.fmt */
+  INT cxMin;
 } COLUMN_INFO;
 
 typedef struct tagITEMHDR
@@ -5733,6 +5734,9 @@ static BOOL LISTVIEW_GetColumnT(const LISTVIEW_INFO *infoPtr, INT nColumn, LPLVC
     if (lpColumn->mask & LVCF_SUBITEM)
 	lpColumn->iSubItem = hdi.lParam;
 
+    if (lpColumn->mask & LVCF_MINWIDTH)
+	lpColumn->cxMin = lpColumnInfo->cxMin;
+
     return TRUE;
 }
 
@@ -7456,6 +7460,7 @@ static INT LISTVIEW_InsertColumnT(LISTVIEW_INFO *infoPtr, INT nColumn,
     if (DPA_InsertPtr(infoPtr->hdpaColumns, nNewColumn, lpColumnInfo) == -1) goto fail;
 
     if (lpColumn->mask & LVCF_FMT) lpColumnInfo->fmt = lpColumn->fmt;
+    if (lpColumn->mask & LVCF_MINWIDTH) lpColumnInfo->cxMin = lpColumn->cxMin;
     if (!SendMessageW(infoPtr->hwndHeader, HDM_GETITEMRECT, nNewColumn, (LPARAM)&lpColumnInfo->rcHeader))
         goto fail;
 
@@ -7535,7 +7540,7 @@ static BOOL LISTVIEW_SetColumnT(const LISTVIEW_INFO *infoPtr, INT nColumn,
     if (lpColumn->mask & LVCF_FMT)
     {
 	COLUMN_INFO *lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, nColumn);
-	int oldFmt = lpColumnInfo->fmt;
+	INT oldFmt = lpColumnInfo->fmt;
 	
 	lpColumnInfo->fmt = lpColumn->fmt;
 	if ((oldFmt ^ lpColumn->fmt) & (LVCFMT_JUSTIFYMASK | LVCFMT_IMAGE))
@@ -7544,6 +7549,9 @@ static BOOL LISTVIEW_SetColumnT(const LISTVIEW_INFO *infoPtr, INT nColumn,
 	}
     }
 
+    if (lpColumn->mask & LVCF_MINWIDTH)
+	LISTVIEW_GetColumnInfo(infoPtr, nColumn)->cxMin = lpColumn->cxMin;
+
     return TRUE;
 }
 
@@ -7679,7 +7687,7 @@ static BOOL LISTVIEW_SetColumnWidth(LISTVIEW_INFO *infoPtr, INT nColumn, INT cx)
 
     /* call header to update the column change */
     hdi.mask = HDI_WIDTH;
-    hdi.cxy = cx;
+    hdi.cxy = max(cx, LISTVIEW_GetColumnInfo(infoPtr, nColumn)->cxMin);
     TRACE("hdi.cxy=%d\n", hdi.cxy);
     return SendMessageW(infoPtr->hwndHeader, HDM_SETITEMW, nColumn, (LPARAM)&hdi);
 }
diff --git a/include/commctrl.h b/include/commctrl.h
index 17d8b86..1e13f10 100644
--- a/include/commctrl.h
+++ b/include/commctrl.h
@@ -2989,6 +2989,7 @@ static const WCHAR WC_LISTVIEWW[] = { 'S','y','s',
 #define LVCF_SUBITEM            0x0008
 #define LVCF_IMAGE              0x0010
 #define LVCF_ORDER              0x0020
+#define LVCF_MINWIDTH           0x0040
 
 #define LVCFMT_LEFT             0x0000
 #define LVCFMT_RIGHT            0x0001
-- 
1.5.6.5







More information about the wine-patches mailing list