[PATCH] comctl32/listview: Add Get/SetSelectedColumn() support

Eric Wheeler wine-devel at lists.ewheeler.net
Thu Aug 27 19:36:28 CDT 2020


In some programs using listview with columns, the first column of the
listbox will select but is not editable and the remaining columns do not
respond to clicking. When clicking one of the checkboxes in the column
nothing happens and you get these two errors in the console:

  0118:err:listview:LISTVIEW_WindowProc unknown msg 108c wp=00000004 lp=00000000
  0118:err:listview:LISTVIEW_WindowProc unknown msg 10ae wp=00000000 lp=00000000

We find that include/commctrl.h defines these as follows:
  #define LVM_SETSELECTEDCOLUMN   (LVM_FIRST + 140) /* 108c is 0x1000 + 140 */
  #define LVM_GETSELECTEDCOLUMN   (LVM_FIRST + 174) /* 10ae is 0x1000 + 174 */

Changes:
  * These defines were removed from the TODO seciton
  * An INT was added to the LISTVIEW_INFO structure to track the selected column
  * LISTVIEW_WindowProc() case statements were added to handle the mapping.

Fixes: https://forum.winehq.org/viewtopic.php?f=8&t=34287
Signed-off-by: Eric Wheeler <wine at linux.ewheeler.net>

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index dba16d1..92e8faa 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -99,7 +99,6 @@
  *   -- LVM_GETINSERTMARKRECT
  *   -- LVM_GETNUMBEROFWORKAREAS
  *   -- LVM_GETOUTLINECOLOR, LVM_SETOUTLINECOLOR
- *   -- LVM_GETSELECTEDCOLUMN, LVM_SETSELECTEDCOLUMN
  *   -- LVM_GETISEARCHSTRINGW, LVM_GETISEARCHSTRINGA
  *   -- LVM_GETTILEINFO, LVM_SETTILEINFO
  *   -- LVM_GETTILEVIEWINFO, LVM_SETTILEVIEWINFO
@@ -248,6 +247,7 @@ typedef struct tagLISTVIEW_INFO
   /* columns */
   HDPA hdpaColumns;		/* array of COLUMN_INFO pointers */
   BOOL colRectsDirty;		/* trigger column rectangles requery from header */
+  INT iSelectedColumn;  /* for use with Set/GetSelectedColumn() */
 
   /* item metrics */
   BOOL bNoItemMetrics;		/* flags if item metrics are not yet computed */
@@ -11465,7 +11465,8 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
   /* case LVM_GETOUTLINECOLOR: */
 
-  /* case LVM_GETSELECTEDCOLUMN: */
+  case LVM_GETSELECTEDCOLUMN:
+    return infoPtr->iSelectedColumn;
 
   case LVM_GETSELECTEDCOUNT:
     return LISTVIEW_GetSelectedCount(infoPtr);
@@ -11638,7 +11639,9 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
   /* case LVM_SETOUTLINECOLOR: */
 
-  /* case LVM_SETSELECTEDCOLUMN: */
+  case LVM_SETSELECTEDCOLUMN:
+	infoPtr->iSelectedColumn = (INT)wParam;
+	return TRUE;
 
   case LVM_SETSELECTIONMARK:
     return LISTVIEW_SetSelectionMark(infoPtr, (INT)lParam);



More information about the wine-devel mailing list