RtreeView.cpp
资源名称:PasRTDat.rar [点击查看]
上传用户:shtiemo
上传日期:2017-12-29
资源大小:163k
文件大小:5k
源码类别:
能源行业(电力石油煤炭)
开发平台:
Visual C++
- // RtreeView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "PasRTDat.h"
- #include "RtreeView.h"
- #include "PwrNet.h"
- #include "PasRTDatDoc.h"
- #include "RtListView.h"
- #include "RTDatOpr.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CRtreeView
- IMPLEMENT_DYNCREATE(CRtreeView, CTreeView)
- CRtreeView::CRtreeView()
- {
- }
- CRtreeView::~CRtreeView()
- {
- }
- BEGIN_MESSAGE_MAP(CRtreeView, CTreeView)
- //{{AFX_MSG_MAP(CRtreeView)
- ON_WM_CREATE()
- ON_WM_LBUTTONDBLCLK()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CRtreeView drawing
- void CRtreeView::OnDraw(CDC* pDC)
- {
- CDocument* pDoc = GetDocument();
- // TODO: add draw code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CRtreeView diagnostics
- #ifdef _DEBUG
- void CRtreeView::AssertValid() const
- {
- CTreeView::AssertValid();
- }
- void CRtreeView::Dump(CDumpContext& dc) const
- {
- CTreeView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CRtreeView message handlers
- CPasRTDatDoc* CRtreeView::GetDoc()
- {
- return (CPasRTDatDoc*)GetDocument();
- }
- int CRtreeView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- lpCreateStruct->style |= TVS_HASBUTTONS|TVS_HASLINES
- |TVS_LINESATROOT;
- if (CTreeView::OnCreate(lpCreateStruct) == -1)
- return -1;
- // TODO: Add your specialized creation code here
- GetDoc()->m_pTreeV = this;
- return 0;
- }
- #define MAXITEMID 42
- void CRtreeView::OnInitialUpdate()
- {
- CTreeView::OnInitialUpdate();
- FillTree();
- // TODO: Add your specialized code here and/or call the base class
- }
- void CRtreeView::FillTree()
- {
- CBitmap bitmap;
- //CRTNETApp *pApp;
- UINT iItem;
- int nParentItem[ITEM_DEEP];
- UINT nBitmapClose[ITEM_DEEP] = {
- IDB_ROOTCLOSE, // 0
- IDB_FIRSTCLOSE, // 1
- IDB_SECONDCLOSE, // 2
- };
- UINT nBitmapOpen[ITEM_DEEP] = {
- IDB_ROOTOPEN, // 0
- IDB_FIRSTOPEN, // 1
- IDB_SECONDOPEN, // 2
- };
- m_imagelist.Create(16, 16, TRUE/*bMask*/, MAXITEMID, MAXITEMID);
- for (UINT i = 0; i < ITEM_DEEP; i++) // load bitmaps for dog, bird and fish
- {
- bitmap.LoadBitmap(nBitmapClose[i]);
- m_imagelist.Add(&bitmap, (COLORREF)0xFFFFFF);
- bitmap.DeleteObject();
- bitmap.LoadBitmap(nBitmapOpen[i]);
- m_imagelist.Add(&bitmap, (COLORREF)0xFFFFFF);
- bitmap.DeleteObject();
- }
- GetTreeCtrl().SetImageList(&m_imagelist, TVSIL_NORMAL);
- iItem = 0;
- nParentItem[0] = iItem;
- CString SQL,CZmingzi,Rootname;
- CPwrNet PwrNet;
- if (PwrNet.Open(CRecordset::forwardOnly, NULL, CRecordset::readOnly))
- {
- CZmingzi = PwrNet.m_MingZi;
- PwrNet.Close();
- }
- /*CRecordset m_rec(GetDoc()->m_pSet);
- CString SQL,CZmingzi,Rootname;
- SQL.Format("select * from DianWang");
- if (m_rec.Open(CRecordset::forwardOnly ,SQL,CRecordset::readOnly))
- {
- m_rec.GetFieldValue("MingZi",CZmingzi);
- }
- m_rec.Close();*/
- Rootname = CZmingzi + " RTDAT 监视一览";
- AddOneItem( 0, -1, 0, Rootname.GetBuffer(32), iItem++ );
- {
- nParentItem[1] = iItem;
- AddOneItem( 1, nParentItem[0], 1, _T("RTU 信息一览"), iItem++ );
- {
- AddOneItem( 2, nParentItem[1], 11, _T("RTU 遥测一览"), iItem++ );
- AddOneItem( 2, nParentItem[1], 12, _T("RTU 遥信一览"), iItem++ );
- }
- }
- SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE) | TVS_SHOWSELALWAYS | TVS_DISABLEDRAGDROP | TVS_LINESATROOT | TVS_HASLINES | TVS_HASBUTTONS );
- SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
- }
- void CRtreeView::AddOneItem( int nGrade, int nParentItem, LPARAM lParam, char* szItemName, UINT iItem )
- {
- TV_INSERTSTRUCT tvstruct;
- if ( nParentItem == -1 )
- {
- tvstruct.hParent = NULL;
- }
- else
- {
- tvstruct.hParent = m_rghItem[nParentItem];
- }
- tvstruct.item.lParam = lParam;
- tvstruct.hInsertAfter = TVI_LAST;
- tvstruct.item.iImage = 2*nGrade;
- tvstruct.item.iSelectedImage = 2*nGrade+1;
- tvstruct.item.pszText = szItemName;
- tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
- m_rghItem[iItem] = GetTreeCtrl().InsertItem(&tvstruct);
- }
- void CRtreeView::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- HTREEITEM hTreeItem;
- CString NodeName;
- int start,Infonum;
- CTreeCtrl &pTreeCtrl = GetTreeCtrl();
- hTreeItem = pTreeCtrl.GetSelectedItem();
- if (hTreeItem)
- {
- NodeName = pTreeCtrl.GetItemText(hTreeItem);
- }
- if(NodeName=="RTU 遥测一览")
- {
- GetDoc()->m_pListV->InitialList();
- if (gRtuID == 9999)
- {
- start = 0;
- Infonum = YCInfoAry1.GetSize();
- }
- else
- {
- start = GetRTUYXYCStartIdx(gRtuID,1);
- if (start < 0)
- {
- start = 0;
- Infonum = 0;
- }
- else
- Infonum = GetRTUYCYXNum(gRtuID,1,start);
- }
- GetDoc()->m_pListV->FillListYC(start, Infonum);
- }
- else if (NodeName=="RTU 遥信一览")
- {
- GetDoc()->m_pListV->InitialList();
- if (gRtuID == 9999)
- {
- start = 0;
- Infonum = YXInfoAry1.GetSize();
- }
- else
- {
- start = GetRTUYXYCStartIdx(gRtuID,2);
- if (start < 0)
- {
- start = 0;
- Infonum = 0;
- }
- else
- Infonum = GetRTUYCYXNum(gRtuID,2,start);
- }
- GetDoc()->m_pListV->FillListYX(start, Infonum);
- }
- CTreeView::OnLButtonDblClk(nFlags, point);
- }