主要用到的類有
CListCtrl
簡述步驟如下
DWORD dwStyle = GetWindowLong(m_tree
dwStyle |= TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT;
SetWindowLong(m_tree
m_hRoot = m_tree
InsertItem()的函數原形為
HTREEITEM InsertItem( LPCTSTR lpszItem
HTREEITEM hInsertAfter = TVI_LAST );
{
size_t szAllDriveStrings = GetLogicalDriveStrings(
char *pDriveStrings = new char[szAllDriveStrings + sizeof(_T(
GetLogicalDriveStrings(szAllDriveStrings
size_t szDriveString = strlen(pDriveStrings);
while(szDriveString >
{
m_tree
pDriveStrings += szDriveString +
szDriveString = strlen(pDriveStrings);
}
}
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
TVITEM item = pNMTreeView
if(item
return;
HTREEITEM hChild = m_tree
while(hChild)
{
AddSubDir(hChild);
hChild = m_tree
}
*pResult =
}
AddSubDir函數功能添加子項
{
m_list
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
TVITEM item = pNMTreeView
if(item
return;
CString str = GetFullPath(item
if(str
str +=
str +=
CFileFind file;
BOOL bContinue = file
while(bContinue)
{
bContinue = file
if(!file
{
SHFILEINFO info;
CString temp = str;
int index = temp
temp
SHGetFileInfo(temp + file
&info
SHGFI_DISPLAYNAME | SHGFI_ICON);
int i = m_ImageList
m_list
}
}
*pResult =
}
這只是一個簡單的例子
VC初學者
From:http://tw.wingwit.com/Article/program/net/201311/12063.html