VC++
Article: Creation of a Tree Control, Create MFC
CTreeCtrl in dialog
|
|
The concept of a tree
list is implemented in the MFC
library by the
CTreeCtrl class. To
create a tree list
on a dialog box or a
form, at design time, on the Controls toolbox, click the
Tree Control button
and click the desired area on a dialog box or a form:
Alternatively, to programmatically create a tree list,
declare a variable or a pointer to
CTreeCtrl. To initialize the control, call
its Create() method. Here is an
example:
private:
CTreeCtrl *TreeSoft;
};
-----------------------------------------------------
// Tree1Dlg.cpp : implementation file
//
CTree1Dlg::CTree1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CTree1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTree1Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
TreeSoft = new CTreeCtrl;
}
CTree1Dlg::~CTree1Dlg()
{
delete TreeSoft;
}
BOOL CTree1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
TreeSoft->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP,
CRect(10, 10, 240, 280), this, 0x1221);
return TRUE; // return TRUE unless you set the focus to a control
}
Next->TVS_CHECKBOXES,TVS_NOTOOLTIPS,TVS_HASLINES,TVS_HASBUTTONS,TVS_SHOWSELALWAYS,TVS_EDITLABELS-MFC-Tree-Control |