home *** CD-ROM | disk | FTP | other *** search
- // TreeDialog.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "allctls.h"
- #include "TreeDlg.h"
- #include "branch.h"
- #include "ptreedef.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CTreeDialog dialog
-
-
- CTreeDialog::CTreeDialog(CWnd* pParent /*=NULL*/)
- : CDialog(CTreeDialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CTreeDialog)
- //}}AFX_DATA_INIT
- }
-
-
- void CTreeDialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CTreeDialog)
- DDX_Control(pDX, IDC_TREEVIEW1, m_treeview);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CTreeDialog, CDialog)
- //{{AFX_MSG_MAP(CTreeDialog)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CTreeDialog message handlers
-
- BOOL CTreeDialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- CBranch parent;
-
- //root = m_treeview.GetBranches();
-
- parent = m_treeview.GetBranches().Add(pvtPositionInOrder, 0, "Parent Node");
- parent.Select(pvtNode);
- parent.Add(pvtPositionInOrder, 0, "Child Node 1 ");
- parent.Add(pvtPositionInOrder, 0, "Child Node 2");
- parent.Add(pvtPositionInOrder, 0, "Child Node 3");
- parent = m_treeview.GetBranches().Add(pvtPositionInOrder, 0, "Parent Node");
- parent.Add(pvtPositionInOrder, 0, "Child Node 4");
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- BEGIN_EVENTSINK_MAP(CTreeDialog, CDialog)
- //{{AFX_EVENTSINK_MAP(CTreeDialog)
- ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 3 /* Up */, OnUpMultibtnctrl1, VTS_NONE)
- ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 4 /* Down */, OnDownMultibtnctrl1, VTS_NONE)
- ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 1 /* Left */, OnLeftMultibtnctrl1, VTS_NONE)
- ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 2 /* Right */, OnRightMultibtnctrl1, VTS_NONE)
- ON_EVENT(CTreeDialog, IDC_BUTTON1, -600 /* Click */, OnClickButton1, VTS_NONE)
- ON_EVENT(CTreeDialog, IDC_TREEVIEW1, -602 /* KeyDown */, OnKeyDownTreeview1, VTS_PI2 VTS_I2)
- //}}AFX_EVENTSINK_MAP
- END_EVENTSINK_MAP()
-
- void CTreeDialog::OnUpMultibtnctrl1()
- {
- // TODO: Add your control notification handler code here
- CBranch Selected;
-
- Selected = m_treeview.GetBranches().Get(pvtGetNextSelected,0);
- Selected = Selected.Get(pvtGetPrevVisible,0);
- if (!Selected.IsValid())
- Selected = m_treeview.GetBranches().Get(pvtGetChild, 0);
-
- Selected.Select(pvtNode);
- }
-
- void CTreeDialog::OnDownMultibtnctrl1()
- {
- // TODO: Add your control notification handler code here
- CBranch Selected;
-
- // gets the currently selected item
- Selected = m_treeview.GetBranches().Get(pvtGetNextSelected,0);
-
- if (Selected.IsValid())
- {
- // gets the next visible item
- Selected = Selected.Get(pvtGetNextVisible,0);
-
- // selects the item
- Selected.Select(pvtNode);
- }
- }
-
- void CTreeDialog::OnLeftMultibtnctrl1()
- {
- // TODO: Add your control notification handler code here
- CBranch Selected;
-
- Selected = m_treeview.GetBranches().Get(pvtGetNextSelected, 0);
- Selected.Clear();
- Selected.Remove();
- }
-
- void CTreeDialog::OnRightMultibtnctrl1()
- {
- // TODO: Add your control notification handler code here
- CBranch Selected;
-
- Selected = m_treeview.GetBranches().Get(pvtGetNextSelected, 0);
- if (!Selected.IsValid())
- return;
-
- Selected.Add(pvtPositionInOrder, 0, "Newly inserted Child Node");
- }
-
- void CTreeDialog::OnClickButton1()
- {
- // TODO: Add your control notification handler code here
- m_treeview.GetBranches().Add(pvtPositionInOrder, 0, "New Parent Node");
- }
-
- void CTreeDialog::OnKeyDownTreeview1(short FAR* KeyCode, short Shift)
- {
- // TODO: Add your control notification handler code here
- if (*KeyCode == VK_RETURN)
- m_treeview.BeginInPlaceEdit();
-
- }
-