ChildFrm.cpp
资源名称:PasRTDat.rar [点击查看]
上传用户:shtiemo
上传日期:2017-12-29
资源大小:163k
文件大小:5k
源码类别:
能源行业(电力石油煤炭)
开发平台:
Visual C++
- // ChildFrm.cpp : implementation of the CChildFrame class
- //
- #include "stdafx.h"
- #include "PasRTDat.h"
- #include "RtreeView.h"
- #include "RtListView.h"
- #include "PasRTDatView.h"
- #include "ChildFrm.h"
- #include "RTDatOpr.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame
- IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
- BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
- //{{AFX_MSG_MAP(CChildFrame)
- ON_WM_CREATE()
- ON_CBN_DROPDOWN(IDC_RTUNAME, OnDropdownRtuname)
- ON_CBN_CLOSEUP(IDC_RTUNAME, OnCloseupRtuname)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame construction/destruction
- CChildFrame::CChildFrame()
- {
- // TODO: add member initialization code here
- barRTUID = short(9999);
- }
- CChildFrame::~CChildFrame()
- {
- }
- BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CMDIChildWnd::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame diagnostics
- #ifdef _DEBUG
- void CChildFrame::AssertValid() const
- {
- CMDIChildWnd::AssertValid();
- }
- void CChildFrame::Dump(CDumpContext& dc) const
- {
- CMDIChildWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CChildFrame message handlers
- BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
- {
- // TODO: Add your specialized code here and/or call the base class
- if (!m_wndSplitter.CreateStatic(this, 1, 2))
- {
- TRACE0("Failed to CreateStaticSplittern");
- return FALSE;
- }
- CRect rect;
- GetClientRect(&rect);
- CSize sizeTree = rect.Size();
- CSize sizeList = rect.Size();
- sizeTree.cx = rect.Width()/3;
- sizeList.cx = rect.Width()*2/3;
- if (!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CRtreeView),sizeTree,pContext))
- {
- TRACE0("Failed to create first panen");
- return FALSE;
- }
- if (!m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CRtListView),sizeList,pContext))
- {
- TRACE0("Failed to create second panen");
- return FALSE;
- }
- SetActiveView((CView*) m_wndSplitter.GetPane(0,1));
- return TRUE;
- }
- int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- if(!m_RtuDlg.Create(this,IDD_RTUBAR,
- CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE,ID_RTUDIALOGBAR))
- {
- TRACE0("Failed to create RtuDlg barn");
- return -1; // fail to create
- }
- m_RtuDlg.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_RtuDlg);
- CWnd* pWnd = m_RtuDlg.GetDlgItem( IDC_RTUNAME ) ;
- pWnd->SendMessage( CB_SETCURSEL , 0 , 0 ) ;
- // TODO: Add your specialized creation code here
- return 0;
- }
- void CChildFrame::OnDropdownRtuname()
- {
- // TODO: Add your control notification handler code here
- CWnd* pwnd ;
- // 获得RTU名列表窗口句柄
- pwnd = m_RtuDlg.GetDlgItem( IDC_RTUNAME ) ;
- // 清RTU名列表内容
- pwnd -> SendMessage( CB_RESETCONTENT , 0 , 0 ) ;
- // RTU名列表
- int num = RtuAry.GetSize();
- pwnd->SendMessage( CB_INITSTORAGE , (WPARAM)(int)(num+1) , (LPARAM)(DWORD)(num*64) ) ;
- pwnd->SendMessage( CB_SETITEMDATA , (WPARAM)(pwnd->SendMessage(CB_ADDSTRING , 0 , (LPARAM)("所有RTU")) ) , 9999 ) ;
- if (barRTUID == 9999)
- pwnd->SendMessage( CB_SETCURSEL , 0 , 0 ) ;
- for( int i = 0 ; i < num ; i ++ )
- {
- LRESULT lr = pwnd->SendMessage( CB_ADDSTRING , 0 , (LPARAM)(LPCTSTR)(RtuAry[i]->szName) ) ;
- pwnd->SendMessage( CB_SETITEMDATA , (WPARAM)lr , (LPARAM)(MAKELONG(RtuAry[i]->nRtuID,0 )) ) ;
- if (barRTUID == RtuAry[i]->nRtuID)
- pwnd->SendMessage( CB_SETCURSEL , (WPARAM)lr , 0 ) ;
- }
- }
- void CChildFrame::OnCloseupRtuname()
- {
- // TODO: Add your control notification handler code here
- CWnd* pwnd ;
- pwnd = m_RtuDlg.GetDlgItem( IDC_RTUNAME) ;
- LRESULT rslt = pwnd->SendMessage( CB_GETCURSEL , 0 , 0 ) ;
- rslt = pwnd->SendMessage( CB_GETITEMDATA , (WPARAM)rslt , 0 ) ;
- if( LOWORD(rslt) == barRTUID )
- return ;
- barRTUID = (short int)(rslt) ;
- gRtuID = barRTUID;
- CRtListView *m_ListV = (CRtListView *)m_wndSplitter.GetPane(0,1);
- CRtreeView *m_TreeV = (CRtreeView *)m_wndSplitter.GetPane(0,0);
- HTREEITEM hTreeItem;
- CString NodeName;
- int YCYX,num,start;
- CTreeCtrl &pTreeCtrl = m_TreeV->GetTreeCtrl();
- hTreeItem = pTreeCtrl.GetSelectedItem();
- if (hTreeItem)
- NodeName = pTreeCtrl.GetItemText(hTreeItem);
- if(NodeName=="RTU 遥测一览")
- {
- YCYX = 1;
- num = YCInfoAry1.GetSize();
- }
- else if (NodeName=="RTU 遥信一览")
- {
- YCYX = 2;
- num = YXInfoAry1.GetSize();
- }
- if (barRTUID == 9999)
- {
- if (YCYX == 1)
- m_ListV->FillListYC(0,num);
- else
- m_ListV->FillListYX(0,num);
- }
- else
- {
- start = GetRTUYXYCStartIdx(barRTUID,YCYX);
- if (start < 0)
- {
- num = 0;
- start = 0;
- }
- else
- num = GetRTUYCYXNum(barRTUID,YCYX,start);
- if (YCYX == 1)
- m_ListV->FillListYC(start,num);
- else
- m_ListV->FillListYX(start,num);
- }
- }