程序切换功能

来源:互联网 发布:12377网络举报app 编辑:程序博客网 时间:2024/05/13 09:22

 1.使用ClistCtrl并添加图标

添加一个ListCtrl并映射变量为m_ListCtrl,并代码中定义保存图标的ImageList变量:
CImageList m_ImageList;
在初始化时给m_ImageList加载小图标。

m_ImageList.Create(20, 20, ILC_COLOR32, 2, 1);

HICON hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
m_ImageList.Add(hIcon);

hIcon = AfxGetApp()->LoadIcon(IDI_ICON2);
m_ImageList.Add(hIcon);

然后将m_ListCtrl和m_ImageList关联,
m_ListCtrl.SetImageList(&m_ImageList, LVSIL_SMALL);

最后在给ListCtrl添加Item就可以了。
m_RelationShipList.InsertItem(i, " ", nIndex);//nIndex是ImageList里的小图标的下标

 

 

 

CListCtrl 使用技巧

yjukh收录,使用标签:CListCtrl, 使用技巧,时间:2007-3-23 15:18:23 | 相关网摘,我也收藏

1. CListCtrl 风格
LVS_ICON: 为每个item显示大图标
LVS_SMALLICON: 为每个item显示小图标
LVS_LIST: 显示一列带有小图标的item
LVS_REPORT: 显示item详细资料

直观的理解:windows资源管理器,“查看”标签下的“大图标,小图标,列表,详细资料”





--------------------------------------------------------------------------------

2. 设置listctrl 风格及扩展风格
LONG lStyle;
lStyle = GetWindowLong(m_list.m_hWnd, GWL_STYLE);//获取当前窗口style
lStyle &= ~LVS_TYPEMASK; //清除显示方式位
lStyle |= LVS_REPORT; //设置style
SetWindowLong(m_list.m_hWnd, GWL_STYLE, lStyle);//设置style

DWORD dwStyle = m_list.GetExtendedStyle();
dwStyle |= LVS_EX_FULLROWSELECT;//选中某行使整行高亮(只适用与report风格的listctrl)
dwStyle |= LVS_EX_GRIDLINES;//网格线(只适用与report风格的listctrl)
dwStyle |= LVS_EX_CHECKBOXES;//item前生成checkbox控件
m_list.SetExtendedStyle(dwStyle); //设置扩展风格