const
  AutoSizeWidth = LVSCW_AUTOSIZE{_USEHEADER};

in C:\lazarus\lcl\interfaces\win32\win32wscustomlistview.inc

this was done in revision 24774 by Paul and the commit message was
"don't reset autosized width of listview column".

I suppose this was originally meant to use  LVSCW_AUTOSIZE_USEHEADER
instead of LVSCW_AUTOSIZE. I have tried to modify it and use
LVSCW_AUTOSIZE_USEHEADER wherever LVSCW_AUTOSIZE is used (see attached
diff) (there is another occurrence in TWin32WSCustomListView.ItemSetText
where the above constant is not used (obviously forgotten to substitute
it) and there it must also be set to LVSCW_AUTOSIZE_USEHEADER) and now
the listview will correctly include the column header in the
calculation. I can't see any "resetting" of the width or any other
unwanted behavior, instead it now behaves as one would expect from it.

Bernd
Index: lcl/interfaces/win32/win32wscustomlistview.inc
===================================================================
--- lcl/interfaces/win32/win32wscustomlistview.inc	(Revision 27026)
+++ lcl/interfaces/win32/win32wscustomlistview.inc	(Arbeitskopie)
@@ -16,8 +16,6 @@
 }
 
 { TWin32WSCustomListView }
-const
-  AutoSizeWidth = LVSCW_AUTOSIZE{_USEHEADER};
 
 type
   TLVStyleType = (lsStyle, lsInvert, lsExStyle);
@@ -398,7 +396,7 @@
   then Exit;
 
   if AAutoSize
-  then ListView_SetColumnWidth(ALV.Handle, AIndex, AutoSizeWidth)
+  then ListView_SetColumnWidth(ALV.Handle, AIndex, LVSCW_AUTOSIZE_USEHEADER)
   else ListView_SetColumnWidth(ALV.Handle, AIndex, TListColumnAccess(AColumn).GetStoredWidth);
 end;
 
@@ -477,7 +475,7 @@
   then Exit;
 
   if AColumn.AutoSize
-  then ListView_SetColumnWidth(ALV.Handle, AIndex, AutoSizeWidth)
+  then ListView_SetColumnWidth(ALV.Handle, AIndex, LVSCW_AUTOSIZE_USEHEADER)
   else ListView_SetColumnWidth(ALV.Handle, AIndex, AWidth)
 end;
 
@@ -490,7 +488,7 @@
 
   if AVisible
   then if AColumn.AutoSize
-    then ListView_SetColumnWidth(ALV.Handle, AIndex, AutoSizeWidth)
+    then ListView_SetColumnWidth(ALV.Handle, AIndex, LVSCW_AUTOSIZE_USEHEADER)
     else ListView_SetColumnWidth(ALV.Handle, AIndex, TListColumnAccess(AColumn).GetStoredWidth)
   else ListView_SetColumnWidth(ALV.Handle, AIndex, 0);
 end;
@@ -674,7 +672,7 @@
     ListView_SetItemText(ALV.Handle, AIndex, ASubIndex, PChar(AText));
   {$endif}
   if ALV.Column[ASubIndex].AutoSize then begin
-    ListView_SetColumnWidth(ALV.Handle, ASubIndex, LVSCW_AUTOSIZE);
+    ListView_SetColumnWidth(ALV.Handle, ASubIndex, LVSCW_AUTOSIZE_USEHEADER);
   end;
 end;
 
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to