Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const LVM_SETCOLUMNWIDTH = &H1000 + 30 Const LVSCW_AUTOSIZE = -1 Const LVSCW_AUTOSIZE_USEHEADER = -2
if second
Sub ListViewAdjustColumnWidth(LV As ListView, Optional AccountForHeaders As Boolean) Dim col As Integer, lParam As Long
If AccountForHeaders Then lParam = LVSCW_AUTOSIZE_USEHEADER Else lParam = LVSCW_AUTOSIZE End If
For col = 0 To LV.ColumnHeaders.Count - 1 SendMessageLong LV.hwnd, LVM_SETCOLUMNWIDTH, col, lParam Next End Sub |