MapView.cpp
上传用户:hbytqc8
上传日期:2014-07-31
资源大小:527k
文件大小:4k
- // MapView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "NetMapDoc.h"
- #include "NetMap.h"
- #include "MapView.h"
- #include "Mainfrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMapView
- IMPLEMENT_DYNCREATE(CMapView, CFormView)
- CMapView::CMapView()
- : CFormView(CMapView::IDD)
- {
- //{{AFX_DATA_INIT(CMapView)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- CMapView::~CMapView()
- {
- }
- void CMapView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMapView)
- DDX_Control(pDX, IDC_TREE4, m_vlan);
- DDX_Control(pDX, IDC_TREE3, m_map);
- DDX_Control(pDX, IDC_TAB2, m_tab);
- //}}AFX_DATA_MAP
- }
- void CMapView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
- pMain->pListView=this;
- m_tab.InsertItem(0, _T("设备列表") );
- m_tab.InsertItem(1, _T("VLAN列表") );
- m_vlan.ShowWindow( SW_HIDE );
- m_iImageList.Create(16, 16, TRUE,1, 0);
- HICON hIcon = NULL;
- //0,root;
- hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_SWITCH), IMAGE_ICON, 16, 16, 0);
- m_iImageList.Add(hIcon);
- //1,closed box;
- hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_RUNVLAN), IMAGE_ICON, 16, 16, 0);
- m_iImageList.Add(hIcon);
- //2,opened box;
- hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_DEADVLAN), IMAGE_ICON, 16, 16, 0);
- m_iImageList.Add(hIcon);
- //3,leaf node
- hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_RUNPORT), IMAGE_ICON, 16, 16, 0);
- m_iImageList.Add(hIcon);
- //4,key node
- hIcon = (HICON)::LoadImage(::AfxGetInstanceHandle(),
- MAKEINTRESOURCE(IDI_DDEADPORT), IMAGE_ICON, 16, 16, 0);
- m_iImageList.Add(hIcon);
- m_vlan.SetImageList (&m_iImageList,TVSIL_NORMAL);
- m_vlan.SetItemHeight(18);
- // HRoot=m_map.InsertItem("Device");
- // HCurrent=m_map.InsertItem("123",HRoot);
- // CNetMapDoc *pDoc=(CNetMapDoc *)GetDocument();
- // MessageBox(pDoc->s);
- }
- BEGIN_MESSAGE_MAP(CMapView, CFormView)
- //{{AFX_MSG_MAP(CMapView)
- ON_NOTIFY(TCN_SELCHANGE, IDC_TAB2, OnSelchangeTab2)
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMapView diagnostics
- #ifdef _DEBUG
- void CMapView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CMapView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMapView message handlers
- void CMapView::OnSelchangeTab2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- int sel = m_tab.GetCurSel();
- switch(sel)
- {
- case 0:
- m_map.ShowWindow( SW_SHOW );
- m_vlan.ShowWindow( SW_HIDE );
- break;
- case 1:
- m_vlan.ShowWindow( SW_SHOW );
- m_map.ShowWindow( SW_HIDE );
- break;
- }
-
- *pResult = 0;
- }
- void CMapView::OnDestroy()
- {
- CFormView::OnDestroy();
- CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
- CMainFrame::NodeData *p;
- for (int i=0;i<pMain->NodeArray.GetSize();i++)
- {
- p=(CMainFrame::NodeData *)m_map.GetItemData(pMain->NodeArray[i]);
- if (p!=NULL)
- {
- if (p->pImage!=NULL) delete p->pImage;
- delete p;
- }
- }
- CMainFrame::Vlan *p1;
- HTREEITEM h;
- h=m_vlan.GetRootItem();
- if (h!=NULL)
- {
- h=m_vlan.GetNextItem(h,TVGN_CHILD);
- p1=(CMainFrame::Vlan *)m_vlan.GetItemData(h);
- if (p1!=NULL) delete p1;
- h=m_vlan.GetNextItem(h,TVGN_NEXT);
- while (h!=NULL)
- {
- p1=(CMainFrame::Vlan*)m_vlan.GetItemData(h);
- if (p1!=NULL) delete p1;
- h=m_vlan.GetNextItem(h,TVGN_NEXT);
- }
- }
- }