图片列表框

下载源文件- 4kb CImageListBox类派生自CListBox,使用CCheckListBox MFC类作为基本思想。 图像列表框显示图像列表。不可能显示文本。 要使用该类,只需将源文件和头文件包含到项目中。将列表框控件添加到对话框资源中。 添加的列表框必须具有以下属性: 所有者draw =固定;无积分高度=假;有字符串=假; 使用ClassWizard为列表框添加一个控件成员变量。作为变量类型选择CImageListBox。 然后,在对话框的OnInitDialog函数中创建一个ImageList,并使用SetImageList函数将其连接到ImageListBox。 使用AddItem函数在ImageListBox中插入

  

元素。 隐藏,复制Code

BOOL CTestDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    m_ImageList.Create(IDB_BITMAP, 40, 0, RGB(255, 255, 255));
    m_lstTest.SetImageList(&m_ImageList);

    for (int i=0; i<10; i++)
        m_lstTest.AddItem(i);

    return TRUE;
}

本文转载于:http://www.diyabc.com/frontweb/news174.html

原文地址:https://www.cnblogs.com/Dincat/p/13431005.html