标签:
源代码及可执行文件下载地址:http://files.cnblogs.com/rainboy2010/CListBoxST.zip
CListBoxST是MFC CListBox的一个派生类,小巧实用,主要的功能特色有:
使用方法
1. 添加ListBoxST.h,ListBoxST.cpp文件到你的项目中
2. 添加List Box控件,名称为IDC_LIST1,设置相应的属性:
3. 添加图标资源到项目中,命名为IDI_Page01~IDI_Page06,并添加以下成员变量:
CListBoxST m_ListBox;
CImageList m_ImageList;
4. 在OnInitDialog()方法里添加以下代码:
m_ListBox.SubclassDlgItem(IDC_LIST1,this);
HICON hIcon=NULL;
m_ImageList.Create(16,16,ILC_COLOR32|ILC_MASK,6,1);
hIcon=AfxGetApp()->LoadIcon(IDI_Page01);
m_ImageList.Add(hIcon);
hIcon=AfxGetApp()->LoadIcon(IDI_Page02);
m_ImageList.Add(hIcon);
hIcon=AfxGetApp()->LoadIcon(IDI_Page03);
m_ImageList.Add(hIcon);
hIcon=AfxGetApp()->LoadIcon(IDI_Page04);
m_ImageList.Add(hIcon);
hIcon=AfxGetApp()->LoadIcon(IDI_Page05);
m_ImageList.Add(hIcon);
hIcon=AfxGetApp()->LoadIcon(IDI_Page06);
m_ImageList.Add(hIcon);
m_ListBox.SetImageList(&m_ImageList);
m_ListBox.AddString(_T("Java is one of the most popular programming languages in the world"),0);
m_ListBox.AddString(_T("C++ is a classic,powerful programming language"),1);
m_ListBox.AddString(_T("C# is an object-oriented,high-level programming language"),2);
m_ListBox.AddString(_T("Python is a programming language that lets you work quickly and integrate systems more effectively"),3);
m_ListBox.AddString(_T("Delphi is famous Windows platform of rapid application development tools"),4);
m_ListBox.AddString(_T("VB is a Visual programming language"),5);
m_ListBox.EnableToolTips(TRUE);
运行效果如下图所示:
标签:
原文地址:http://www.cnblogs.com/rainboy2010/p/4268886.html