Add AutoSize option for a column

Summary

Id: 4089.24
Type: Issue Issue
Current Status: Open

Detail

6 Feb 2004 Open Joshua Lippiner

Feature Request - COLUMN AUTO SIZE. There is currently no way to resize the columns based on either the header or contents of the column. My attempts to subclass failed.

8 Feb 2004 Open Steve McMahon

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.