- 浏览: 71183 次
- 性别:
- 来自: 上海
文章分类
最新评论
20. listctrl的subitem添加图标
m_list.SetExtendedStyle(LVS_EX_SUBITEMIMAGES);
m_list.SetItem(..); //具体参数请参考msdn
21. 在CListCtrl显示文件,并根据文件类型来显示图标
网上找到的代码,share
BOOL CTest6Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
HIMAGELIST himlSmall;
HIMAGELIST himlLarge;
SHFILEINFO sfi;
char cSysDir[MAX_PATH];
CString strBuf;
memset(cSysDir, 0, MAX_PATH);
GetWindowsDirectory(cSysDir, MAX_PATH);
strBuf = cSysDir;
sprintf(cSysDir, "%s", strBuf.Left(strBuf.Find("\\") 1));
himlSmall = (HIMAGELIST)SHGetFileInfo ((LPCSTR)cSysDir,
0,
&sfi,
sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON );
himlLarge = (HIMAGELIST)SHGetFileInfo((LPCSTR)cSysDir,
0,
&sfi,
sizeof(SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_LARGEICON);
if (himlSmall && himlLarge)
{
::SendMessage(m_list.m_hWnd, LVM_SETIMAGELIST,
(WPARAM)LVSIL_SMALL, (LPARAM)himlSmall);
::SendMessage(m_list.m_hWnd, LVM_SETIMAGELIST,
(WPARAM)LVSIL_NORMAL, (LPARAM)himlLarge);
}
return TRUE; // return TRUE unless you set the focus to a control
}
void CTest6Dlg::AddFiles(LPCTSTR lpszFileName, BOOL bAddToDocument)
{
int nIcon = GetIconIndex(lpszFileName, FALSE, FALSE);
CString strSize;
CFileFind filefind;
// get file size
if (filefind.FindFile(lpszFileName))
{
filefind.FindNextFile();
strSize.Format("%d", filefind.GetLength());
}
else
strSize = "0";
// split path and filename
CString strFileName = lpszFileName;
CString strPath;
int nPos = strFileName.ReverseFind('\\');
if (nPos != -1)
{
strPath = strFileName.Left(nPos);
strFileName = strFileName.Mid(nPos 1);
}
// insert to list
int nItem = m_list.GetItemCount();
m_list.InsertItem(nItem, strFileName, nIcon);
m_list.SetItemText(nItem, 1, strSize);
m_list.SetItemText(nItem, 2, strFileName.Right(3));
m_list.SetItemText(nItem, 3, strPath);
}
int CTest6Dlg::GetIconIndex(LPCTSTR lpszPath, BOOL bIsDir, BOOL bSelected)
{
SHFILEINFO sfi;
memset(&sfi, 0, sizeof(sfi));
if (bIsDir)
{
SHGetFileInfo(lpszPath,
FILE_ATTRIBUTE_DIRECTORY,
&sfi,
sizeof(sfi),
SHGFI_SMALLICON | SHGFI_SYSICONINDEX |
SHGFI_USEFILEATTRIBUTES |(bSelected ? SHGFI_OPENICON : 0));
return sfi.iIcon;
}
else
{
SHGetFileInfo (lpszPath,
FILE_ATTRIBUTE_NORMAL,
&sfi,
sizeof(sfi),
SHGFI_SMALLICON | SHGFI_SYSICONINDEX |
SHGFI_USEFILEATTRIBUTES | (bSelected ? SHGFI_OPENICON : 0));
return sfi.iIcon;
}
return -1;
}
22. listctrl内容进行大数据量更新时,避免闪烁
m_list.SetRedraw(FALSE);
//更新内容
m_list.SetRedraw(TRUE);
m_list.Invalidate();
m_list.UpdateWindow();
或者参考
23. listctrl排序
Q250614:How To Sort Items in a CListCtrl in Report View
http://support.microsoft.com/kb/250614/en-us
24. 在listctrl中选中某个item时动态改变其icon或bitmap
Q141834: How to change the icon or the bitmap of a CListCtrl item in Visual C
http://support.microsoft.com/kb/141834/en-us
25. 在添加item后,再InsertColumn()后导致整列数据移动的问题
Q151897: CListCtrl::InsertColumn() Causes Column Data to Shift
http://support.microsoft.com/kb/151897/en-us
26. 关于listctrl第一列始终居左的问题
解决办法:把第一列当一个虚列,从第二列开始插入列及数据,最后删除第一列。
具体解释参阅 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listview/structures/lvcolumn.asp
27. 锁定column header的拖动
http://msdn.microsoft.com/msdnmag/issues/03/06/CQA/
28. 如何隐藏clistctrl的列
把需隐藏的列的宽度设为0,然后检测当该列为隐藏列时,用上面第27点的锁定column 的拖动来实现
29. listctrl进行大数据量操作时,使用virtual list
http://www.microsoft.com/msj/archive/S2061.aspx
http://www.codeguru.com/cpp/controls/listview/advanced/article.php/c4151/
http://www.codeproject.com/listctrl/virtuallist.asp
30. 关于item只能显示259个字符的问题
解决办法:需要在item上放一个edit。
31. 响应在listctrl的column header上的鼠标右键单击
Q125694: How To Find Out Which Listview Column Was Right-Clicked
http://support.microsoft.com/kb/125694/en-us
32. 类似于windows资源管理器的listview
Q234310: How to implement a ListView control that is similar to Windows Explorer by using DirLV.exe
http://support.microsoft.com/kb/234310/en-us
33. 在ListCtrl中OnTimer只响应两次的问题
Q200054:
PRB: OnTimer() Is Not Called Repeatedly for a List Control
http://support.microsoft.com/kb/200054/en-us
34. 以下为一些为实现各种自定义功能的listctrl派生类
(1) 拖放
http://www.codeproject.com/listctrl/dragtest.asp
在CListCtrl和CTreeCtrl间拖放
http://support.microsoft.com/kb/148738/en-us
(2) 多功能listctrl
支持subitem可编辑,图标,radiobutton,checkbox,字符串改变颜色的类
http://www.codeproject.com/listctrl/quicklist.asp
支持排序,subitem可编辑,subitem图标,subitem改变颜色的类
http://www.codeproject.com/listctrl/ReportControl.asp
(3) subitem中显示超链接
http://www.codeproject.com/listctrl/CListCtrlLink.asp
(4) subitem的tooltip提示
http://www.codeproject.com/listctrl/ctooltiplistctrl.asp
(5) subitem中显示进度条
http://www.codeproject.com/listctrl/ProgressListControl.asp
http://www.codeproject.com/listctrl/napster.asp
http://www.codeguru.com/Cpp/controls/listview/article.php/c4187/
(6) 动态改变subitem的颜色和背景色
http://www.codeproject.com/listctrl/highlightlistctrl.asp
http://www.codeguru.com/Cpp/controls/listbox/colorlistboxes/article.php/c4757/
(7) 类vb属性对话框
http://www.codeproject.com/listctrl/propertylistctrl.asp
http://www.codeguru.com/Cpp/controls/listview/propertylists/article.php/c995/
http://www.codeguru.com/Cpp/controls/listview/propertylists/article.php/c1041/
(8) 选中subitem(只高亮选中的item)
http://www.codeproject.com/listctrl/SubItemSel.asp
http://www.codeproject.com/listctrl/ListSubItSel.asp
(9) 改变行高
http://www.codeproject.com/listctrl/changerowheight.asp
(10) 改变行颜色
http://www.codeproject.com/listctrl/coloredlistctrl.asp
(11) 可编辑subitem的listctrl
http://www.codeproject.com/listctrl/nirs2000.asp
http://www.codeproject.com/listctrl/editing_subitems_in_listcontrol.asp
(12) subitem可编辑,插入combobox,改变行颜色,subitem的tooltip提示
http://www.codeproject.com/listctrl/reusablelistcontrol.asp
(13) header 中允许多行字符串
http://www.codeproject.com/listctrl/headerctrlex.asp
(14) 插入combobox
http://www.codeguru.com/Cpp/controls/listview/editingitemsandsubitem/article.php/c979/
(15) 添加背景图片
http://www.codeguru.com/Cpp/controls/listview/backgroundcolorandimage/article.php/c4173/
http://www.codeguru.com/Cpp/controls/listview/backgroundcolorandimage/article.php/c983/
http://www.vchelp.net/vchelp/archive.asp?type_id=9&class_id=1&cata_id=1&article_id=1088&search_term=
(16) 自适应宽度的listctrl
http://www.codeproject.com/useritems/AutosizeListCtrl.asp
(17) 改变ListCtrl高亮时的颜色(默认为蓝色)
处理 NM_CUSTOMDRAW
http://www.codeproject.com/listctrl/lvcustomdraw.asp
(18) 改变header颜色
http://www.pocketpcdn.com/articles/hdr_color.html
发表评论
-
自己写的一段customerDraw
2010-08-24 16:20 1855void CNewReportPage::OnNMCustom ... -
帖BitMap
2010-08-24 09:42 746void CEx_14View::O ... -
clistctrl +号按钮绘制
2010-08-11 17:18 1521网上有关clistctrl举不胜举,包括按钮控件的绘 ... -
VC中使用ListCtrl经验总结(1)
2010-08-11 17:07 1279ListCtrl在工作中,常常用到,也常常看到大家发帖问怎么用 ... -
LV_COLUMN结构体
2010-08-10 14:44 2637typedef struct _LV_COLUMN {UINT ... -
加载位图BITMAP
2010-08-10 14:27 1401m_Bitmap.LoadBitmap(IDB_BITMAP1 ... -
关于控件重绘函数/消息 OnPaint,OnDraw,OnDrawItem,DrawItem的区别
2010-08-10 13:15 6376而OnPaint()是CWnd的类成员,同时负责响应WM_ ... -
listctrl 重绘
2010-08-10 10:15 1012common control 4.7版本介绍 ... -
OnCreate PreCreateWindow PreSubclassWindow
2010-08-09 17:47 1723OnCreate PreCreateWindow PreSub ... -
扩展CListCtrl实现颜色长度改变
2010-08-09 17:34 3163用CListCtrl来显示数据比较方便,有时候我们需要标注某一 ... -
创建CListCtrl中的排序小图标
2010-08-09 17:11 2272创建CListCtrl中的排序小图标 for(int i = ... -
CListCtrl控件的使用
2010-08-09 17:02 1154初始化: DWORD dwStyle; dwStyle = m ... -
改变 CListCtrl、CHeaderCtrl 高度、字体、颜色和背景
2010-08-09 16:49 2566改变 CListCtrl、CHeaderCtrl 高度、字体、 ... -
CHeaderCtrl用法
2010-08-09 15:47 4202CListCtrl的表头可以单独 ... -
CListCtrl::SortItems的用法:
2010-08-09 12:37 1953CListCtrl::SortItems的用法: (一)So ... -
树型视的三个结构TVINSERTSTRUCT、TVITEM、NMTREEVIEW
2010-08-05 18:11 952TVINSERTSTRUCT包含添加新项到树形视控件所使用的信 ... -
剪贴板和OLE拖放
2010-08-05 16:35 1084一、传统剪贴板 ... -
文档/视图结构中的各个部分是如何联系到一起的
2010-08-05 15:39 715文档/视图结构是MFC中最有特色而又有难度的部分,在这当中涉及 ... -
MFC一些函数区别
2010-08-05 13:43 1609GetMessagePos GetCursorPos的区别 ... -
LPTSTR、LPCSTR、LPCTSTR、LPSTR的意义
2010-08-05 13:33 986UNICODE:它是用两个字节 ...
相关推荐
ListCtrl在工作中,常常用到,也常常看到大家发帖问怎么用这个控件,故总结了一下自己的使用经验,以供参考使用。 先注明一下,这里,我们用m_listctrl来表示一个CListCtrl的类对象,然后这里我们的ListCtrl都是...
MFC控件:listctrl使用方法总结
关于LIstCtrl的一些总结,里面知识还算全。。
详细总结了wxpython中Listctrl方法使用。
1. CListCtrl 风格 2. 设置listctrl 风格及扩展风格 3. 插入数据 4. 一直选中item 5. 选中和取消选中一行
最近在做数据库实习,用到一个控件 ListCtrl 感觉挺不错的,拿出来和大家分享一下
主要介绍了VC++ 中ListCtrl经验总结的相关资料,需要的朋友可以参考下
2.为ListCtrl添加变量 右击->添加变量m_wndPath 3.找到OnInitDialog()函数添加如下代码: // TODO: 在此添加额外的初始化代码 m_wndPath.DeleteAllItems();//清空 m_wndPath.InsertColumn(0,_T(项目));//添加列 m_...
下面总结一下我从这本书和其它地方学到的一些常见的设置和技巧(我自认为是中高级的,可是有些读者可能认为某些部分是初级的)。 2.1全局替换 %s/old/new/g 2.2多文件替换 多文件替换,比如要替换所有.c文件中a_...
list:显示制表位(Ctrl+I)和行尾标志($) number:显示行号 report:显示由面向行的命令修改过的数目 terse:显示简短的警告信息 warn:在转到别的文件时若没保存当前文件则显示NO write信息 nomagic:允许在...
演示了其它控件(全部)阙套到List中并自绘等,学习自绘以及阙套CListCtrl 控件的好实例。 ColorStatic 自绘了CStatic控件,实现了标题字符滚动效果。 CSDN免积分下载工具 源码 演示了使用CInternetSession去下载...
前几天搞 Spring + Hibernate + Struts 事务配置 ,网上找了好多资料,不过好无语,大多都是 Ctrl + V,浪费俺的宝贵时间 现在我总结配出一套,给大家参考参考,可能有不足,请大家多多交流。 附:内有弹出...
演示了其它控件(全部)阙套到List中并自绘等,学习自绘以及阙套CListCtrl 控件的好实例。 ColorStatic 自绘了CStatic控件,实现了标题字符滚动效果。 CSDN免积分下载工具 源码 演示了使用CInternetSession去下载...
演示了其它控件(全部)阙套到List中并自绘等,学习自绘以及阙套CListCtrl 控件的好实例。 ColorStatic 自绘了CStatic控件,实现了标题字符滚动效果。 CSDN免积分下载工具 源码 演示了使用CInternetSession去下载...
演示了其它控件(全部)阙套到List中并自绘等,学习自绘以及阙套CListCtrl 控件的好实例。 ColorStatic 自绘了CStatic控件,实现了标题字符滚动效果。 CSDN免积分下载工具 源码 演示了使用CInternetSession去下载...
演示了其它控件(全部)阙套到List中并自绘等,学习自绘以及阙套CListCtrl 控件的好实例。 ColorStatic 自绘了CStatic控件,实现了标题字符滚动效果。 CSDN免积分下载工具 源码 演示了使用CInternetSession去下载...
小编的确一直都想把这方面的命令做个总结,这次辛苦老范给我们整理了这份实用的秘笈。 Bootcfg bootcfg 命令启动配置和故障恢复(对于大多数计算机,即 boot.ini 文件)。 含有下列参数的 bootcfg 命令仅在...
演示了其它控件(全部)阙套到List中并自绘等,学习自绘以及阙套CListCtrl 控件的好实例。 ColorStatic 自绘了CStatic控件,实现了标题字符滚动效果。 CSDN免积分下载工具 源码 演示了使用CInternetSession去下载...
arcgis工具总结 1. 要素的剪切与延伸 实用工具 TASK 任务栏 Extend/Trim feature 剪切所得内容与你画线的方向有关。 2. 自动捕捉跟踪工具 点击Editor工具栏中Snapping来打开Snapping Environment对话框 捕捉设置...