ListView_SetIconSpacing macro

Sets the spacing between icons in list-view controls set to the LVS_ICON style. You can use this macro or send the LVM_SETICONSPACING message explicitly.


DWORD ListView_SetIconSpacing(
   HWND hwndLV,
   int  cx,
   int  cy



Type: HWND

A handle to a list-view control.


Type: int

The distance, in pixels, to set between icons on the x-axis.


Type: int

The distance, in pixels, to set between icons on the y-axis.

Return value

Returns a DWORD value that contains the previous cx in the low word and the previous cy in the high word.


The cx and cy parameters are relative to the upper-left corner of an icon bitmap. Therefore, to set spacing between icons that do not overlap, the cx or cy values must include the size of the icon, plus the amount of empty space desired between icons. Values that do not include the width of the icon will result in overlaps.

When defining the icon spacing, cx and cy must set to 4 or larger. Smaller values will not yield the desired layout. You can reset cx and cy to the default spacing by setting both values to -1. This approach only allows you to reset both default settings. You cannot reset only cx or cy to the default setting by setting one of them to -1.


Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]