C++ ListControl - 图标位置

标签 c++ mfc position icons listcontrol

当我使用“SetIconSpacing”命令时,第一个图标没有放在应有的位置 - 知道为什么吗? (当我不使用 SetIconSpacing 时,它们被均匀地描绘)

代码:

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);

当前的错误行为:

look at the first item

最佳答案

您在设置图像列表之前使用图像索引。正确的顺序是:

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);
}

关于C++ ListControl - 图标位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35975539/

相关文章:

jquery - 单击按钮更改背景位置

c++ - 如何在 64 位版本的 Windows 中调用 SetWindowLong()?

c++ - 重写 MFC 应用程序的 LoadString

mfc - 在 Windows XP 中单击项目复选框时,CTreeCtrl 'TVN_ITEMCHANGED ' 没有被触发?

html - 一个奇怪的 div 的定位和大小

SQL : Find the position of a character in a string value

c++ - 模板符号搜索问题

C++编译错误: unexpected type name 'string' : expected expression

c++ - 如何在第一个调用的构造函数中更正创建和传递对象

c++ - 获取选中的单选按钮的索引