在类里定义了一个CTreeCtrl变量;
class CComplexMfcCtrlsTest : public CDialog
{
// Construction
public:
CComplexMfcCtrlsTest(CWnd* pParent = NULL); // standard constructor
CTreeCtrl m_treeCtrl;
CImageList m_ImageList;然后,在OnCreate函数里,
int CComplexMfcCtrlsTest::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
//this->m_treeCtrl.InsertItem("A",0,0);
m_treeCtrl.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER
| TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES
| TVS_DISABLEDRAGDROP,
CRect(100, 100, 300, 500), this, IDC_TREE1); m_ImageList.Create(IDB_BITMAP1,1,1,RGB(0,0,0));
m_treeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);
HTREEITEM hItem,hSubItem;
hItem = m_treeCtrl.InsertItem("Parent1",TVI_ROOT);//在根结点上添加Parent1
hSubItem = m_treeCtrl.InsertItem("Child1_1",hItem);//在Parent1上添加一个子结点
hSubItem = m_treeCtrl.InsertItem("Child1_2",hItem,hSubItem);//在Parent1上添加一个子结点,排在Child1_1后面
hSubItem = m_treeCtrl.InsertItem("Child1_3",hItem,hSubItem); hItem = m_treeCtrl.InsertItem("Parent2",TVI_ROOT,hItem);
hItem = m_treeCtrl.InsertItem("Parent3",TVI_ROOT,hItem);
return 0;
}
问题是,,显示的树形结构不在CTreeCtrl里,而且在CTreeCtrl下面,不知杂回事...
class CComplexMfcCtrlsTest : public CDialog
{
// Construction
public:
CComplexMfcCtrlsTest(CWnd* pParent = NULL); // standard constructor
CTreeCtrl m_treeCtrl;
CImageList m_ImageList;然后,在OnCreate函数里,
int CComplexMfcCtrlsTest::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
//this->m_treeCtrl.InsertItem("A",0,0);
m_treeCtrl.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER
| TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES
| TVS_DISABLEDRAGDROP,
CRect(100, 100, 300, 500), this, IDC_TREE1); m_ImageList.Create(IDB_BITMAP1,1,1,RGB(0,0,0));
m_treeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);
HTREEITEM hItem,hSubItem;
hItem = m_treeCtrl.InsertItem("Parent1",TVI_ROOT);//在根结点上添加Parent1
hSubItem = m_treeCtrl.InsertItem("Child1_1",hItem);//在Parent1上添加一个子结点
hSubItem = m_treeCtrl.InsertItem("Child1_2",hItem,hSubItem);//在Parent1上添加一个子结点,排在Child1_1后面
hSubItem = m_treeCtrl.InsertItem("Child1_3",hItem,hSubItem); hItem = m_treeCtrl.InsertItem("Parent2",TVI_ROOT,hItem);
hItem = m_treeCtrl.InsertItem("Parent3",TVI_ROOT,hItem);
return 0;
}
问题是,,显示的树形结构不在CTreeCtrl里,而且在CTreeCtrl下面,不知杂回事...
2.在类里定义了一个CTreeCtrl变量;
class CComplexMfcCtrlsTest : public CDialog
{
// Construction
public:
CComplexMfcCtrlsTest(CWnd* pParent = NULL); // standard constructor
CTreeCtrl m_treeCtrl;
CImageList m_ImageList;3.在OnCreate函数里,
int CComplexMfcCtrlsTest::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
//this->m_treeCtrl.InsertItem("A",0,0);
m_treeCtrl.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER
| TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES
| TVS_DISABLEDRAGDROP,
CRect(100, 100, 300, 500), this, IDC_TREE1); m_ImageList.Create(IDB_BITMAP1,1,1,RGB(0,0,0));
m_treeCtrl.SetImageList(&m_ImageList,TVSIL_NORMAL);
HTREEITEM hItem,hSubItem;
hItem = m_treeCtrl.InsertItem("Parent1",TVI_ROOT);//在根结点上添加Parent1
hSubItem = m_treeCtrl.InsertItem("Child1_1",hItem);//在Parent1上添加一个子结点
hSubItem = m_treeCtrl.InsertItem("Child1_2",hItem,hSubItem);//在Parent1上添加一个子结点,排在Child1_1后面
hSubItem = m_treeCtrl.InsertItem("Child1_3",hItem,hSubItem); hItem = m_treeCtrl.InsertItem("Parent2",TVI_ROOT,hItem);
hItem = m_treeCtrl.InsertItem("Parent3",TVI_ROOT,hItem);
return 0;
}
问题是,,显示的树形结构不在CTreeCtrl里,而且在CTreeCtrl下面,不知杂回事...
----------------------------------------------------
???这个是什么意思???