Column AutoSize would be a sensible addition. The LVM_SETCOLUMNWIDTH message in conjunction with LVSCW_AUTOSIZE can achieve this: lResult = SendMessage( // returns LRESULT in lResult
(HWND) hWndControl, // handle to destination control
(UINT) LVM_SETCOLUMNWIDTH, // message ID
(WPARAM) wParam, // = (WPARAM) (int) iCol
(LPARAM) lParam // = (LPARAM) MAKELPARAM ((int) cx, 0)
);
Parameters iCol - Zero-based index of a valid column. For list-view mode, this parameter must be set to zero. cx - New width of the column, in pixels. For report-view mode, the following special values are supported: LVSCW_AUTOSIZE - Automatically sizes the column. LVSCW_AUTOSIZE_USEHEADER - Automatically sizes the column to fit the header text. If you use this value with the last column, its width is set to fill the remaining width of the list-view control. Returns TRUE if successful, or FALSE otherwise. |