Wasined
Wasined

Reputation: 1

C++ ListControl - Icon position

When I use the "SetIconSpacing" command, the first icon isn't placed where it should be - any ideas why? (When I don't use SetIconSpacing they are depicted evenly)

Code:

VZ_Liste.SetIconSpacing(CSize (100,100)); 
verkehrs_icons.Create(64,64,ILC_COLOR32,29,0); 
CString strItem = _T("");
for (int i = 0; i<29; i++) 
{
  verkehrs_icons.Add(AfxGetApp()->LoadIcon(IDI_ICON1 + i)); 
  VZ_Liste.InsertItem(i, strItem, i);
}
VZ_Liste.SetImageList(&verkehrs_icons, LVSIL_NORMAL);

The current wrong behaviour:

look at the first item

Upvotes: 0

Views: 325

Answers (1)

zdf
zdf

Reputation: 4808

You are using the images indexes before setting the image list. The correct sequence is:

VZ_Liste.SetImageList(&verkehrs_icons, LVSIL_NORMAL); // FIRST!
for (int i = 0; i<29; i++) 
{
  verkehrs_icons.Add(AfxGetApp()->LoadIcon(IDI_ICON1 + i)); 
  VZ_Liste.InsertItem(i, strItem, i);
}

Upvotes: 1

Related Questions