TreeCtrlEx.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:10k
- // TreeCtrlEx.cpp : implementation file
- //
- #include "stdafx.h"
- #include "GpsSC.h"
- #include "TreeCtrlEx.h"
- #include "MonitorDlg.h"
- #include "ClientinfoSet.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CTreeCtrlEx
- CTreeCtrlEx::CTreeCtrlEx()
- {
- m_PopMenu.LoadMenu(IDR_POP_MENU);
- m_strCarPhone.Empty(); //车载电话
- m_strPassWord.Empty();
- m_hTreeItem = NULL;
- }
- CTreeCtrlEx::~CTreeCtrlEx()
- {
- m_hTreeItem = NULL;
- }
- BEGIN_MESSAGE_MAP(CTreeCtrlEx, CTreeCtrl)
- //{{AFX_MSG_MAP(CTreeCtrlEx)
- ON_WM_RBUTTONDOWN()
- ON_COMMAND(ID_POP_AUTOMONITOR, OnPopAutomonitor)
- ON_COMMAND(ID_POP_GETHELP, OnPopGethelp)
- ON_COMMAND(ID_POP_GETVEHICLEPOSITION, OnPopGetvehicleposition)
- ON_COMMAND(ID_POP_OPENLOCK, OnPopOpenlock)
- ON_COMMAND(ID_POP_SENDINFOTOGROUP, OnPopSendinfotogroup)
- ON_COMMAND(ID_POP_SENDNORMALSM, OnPopSendnormalsm)
- ON_COMMAND(ID_POP_SETLOCK, OnPopSetlock)
- ON_COMMAND(ID_POP_SHUTOIL, OnPopShutoil)
- ON_UPDATE_COMMAND_UI(ID_POP_SHUTOIL, OnUpdatePopShutoil)
- ON_UPDATE_COMMAND_UI(ID_POP_SETLOCK, OnUpdatePopSetlock)
- ON_UPDATE_COMMAND_UI(ID_POP_SENDNORMALSM, OnUpdatePopSendnormalsm)
- ON_UPDATE_COMMAND_UI(ID_POP_SENDINFOTOGROUP, OnUpdatePopSendinfotogroup)
- ON_UPDATE_COMMAND_UI(ID_POP_OPENLOCK, OnUpdatePopOpenlock)
- ON_UPDATE_COMMAND_UI(ID_POP_GETVEHICLEPOSITION, OnUpdatePopGetvehicleposition)
- ON_UPDATE_COMMAND_UI(ID_POP_GETHELP, OnUpdatePopGethelp)
- ON_UPDATE_COMMAND_UI(ID_POP_AUTOMONITOR, OnUpdatePopAutomonitor)
- ON_WM_LBUTTONDOWN()
- ON_COMMAND(ID_POP_CANCELAUTOMONITOR, OnPopCancelautomonitor)
- ON_UPDATE_COMMAND_UI(ID_POP_CANCELAUTOMONITOR, OnUpdatePopCancelautomonitor)
- ON_COMMAND(ID_POP_SET_CURR_MONITOR_CAR, OnPopSetCurrMonitorCar)
- ON_UPDATE_COMMAND_UI(ID_POP_SET_CURR_MONITOR_CAR, OnUpdatePopSetCurrMonitorCar)
- ON_COMMAND(ID_POP_CANCEL_CURR_MONITOR_CAR, OnPopCancelCurrMonitorCar)
- ON_UPDATE_COMMAND_UI(ID_POP_CANCEL_CURR_MONITOR_CAR, OnUpdatePopCancelCurrMonitorCar)
- ON_WM_INITMENUPOPUP()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTreeCtrlEx message handlers
- void CTreeCtrlEx::OnRButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CTreeCtrl::OnRButtonDown(nFlags, point);
- CRect lpRect;
- HTREEITEM m_hCurrTree;
- m_hCurrTree = HitTest(point);
- if(m_hCurrTree == NULL) {
- return;
- }
- m_hTreeItem = m_hCurrTree;
- m_strGetItemText=GetItemText(m_hCurrTree);
- m_hCurrTree=NULL;
- if(m_strGetItemText.Find("监控")!=-1)
- m_strGetItemText=m_strGetItemText.Left(m_strGetItemText.GetLength()-10);
- GetWindowRect(&lpRect);
- m_pMenu = m_PopMenu.GetSubMenu(0);
- m_pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
- point.x + lpRect.left,
- point.y + lpRect.top, this,NULL);
- }
- bool CTreeCtrlEx::Init(CProcSM *pProcSM)
- {
- if(pProcSM == NULL) return false;
- m_pProcSM = pProcSM;
- return true;
- }
- void CTreeCtrlEx::OnPopAutomonitor()
- {
- // TODO: Add your command handler code here
- m_pProcSM->AutoMonitor(m_strGetItemText);
- }
- void CTreeCtrlEx::OnUpdatePopAutomonitor(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnPopGethelp()
- {
- // TODO: Add your command handler code here
- m_pProcSM->GetHelp();
- }
- void CTreeCtrlEx::OnUpdatePopGethelp(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnPopGetvehicleposition()
- {
- // TODO: Add your command handler code here
- m_pProcSM->OnGetvehicleposition(m_strGetItemText);
- }
- void CTreeCtrlEx::OnUpdatePopGetvehicleposition(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnPopOpenlock()
- {
- // TODO: Add your command handler code here
- m_pProcSM->OnOpenlock(m_strGetItemText);
- }
- void CTreeCtrlEx::OnUpdatePopOpenlock(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnPopSendinfotogroup()
- {
- // TODO: Add your command handler code here
- AfxMessageBox("对不起! 此功能只提供给正式用户!");
- }
- void CTreeCtrlEx::OnUpdatePopSendinfotogroup(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnPopSendnormalsm()
- {
- // TODO: Add your command handler code here
- AfxMessageBox("对不起! 此功能只提供给正式版用户!");
- }
- void CTreeCtrlEx::OnUpdatePopSendnormalsm(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnPopSetlock()
- {
- // TODO: Add your command handler code here
- m_pProcSM->OnSetlock(m_strGetItemText);
- }
- void CTreeCtrlEx::OnUpdatePopSetlock(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnPopShutoil()
- {
- // TODO: Add your command handler code here
- m_pProcSM->OnShutoil(m_strGetItemText);
- }
- void CTreeCtrlEx::OnUpdatePopShutoil(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(m_pProcSM->m_bSysTemInit);
- }
- void CTreeCtrlEx::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- CTreeCtrl::OnLButtonDown(nFlags, point);
- HTREEITEM m_hCurrTree;
- m_hCurrTree = HitTest(point);
- if(m_hCurrTree == NULL) {
- return;
- }
- str_GetTreeItemText = GetItemText(m_hCurrTree);
- m_hCurrTree = NULL;
- }
- bool CTreeCtrlEx::GetCarPhoneAndPassword()
- {
- CClientinfoSet cSet;
- if(!str_GetTreeItemText.IsEmpty()) {
- cSet.FindCarPswAndNO(str_GetTreeItemText,m_strCarPhone,m_strPassWord);
- return true;
- }
- return false;
- }
- void CTreeCtrlEx::OnPopCancelautomonitor()
- {
- // TODO: Add your command handler code here
- m_pProcSM->CanceLautoMonitor(m_strGetItemText);
- if(m_pProcSM->CheckMonitorCar())
- {
- CMainFrame* mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- bool bControl = false;
- mainfrm->EditTreeItem(m_hTreeItem,bControl);
- }
- }
- void CTreeCtrlEx::OnUpdatePopCancelautomonitor(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- BOOL MenuEnable = m_pProcSM->m_bSysTemInit;
- pCmdUI->Enable(MenuEnable);
- }
- void CTreeCtrlEx::OnPopSetCurrMonitorCar()
- {
- // TODO: Add your command handler code here
- CClientinfoSet cSet;
- CString VehicleID,VehicleTel;
- CMainFrame* mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- cSet.FindCarNumberAndPhone(m_strGetItemText,VehicleID,VehicleTel);
- m_pProcSM->SetMonitorCar(VehicleID);
- if(!m_pProcSM->CheckMonitorCar())
- {
- mainfrm->EditTreeItem(m_hTreeItem);
- }
- }
- void CTreeCtrlEx::OnUpdatePopSetCurrMonitorCar(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- BOOL MenuEnable = m_pProcSM->m_bSysTemInit;
- pCmdUI->Enable(MenuEnable);
- }
- void CTreeCtrlEx::OnPopCancelCurrMonitorCar()
- {
- // TODO: Add your command handler code here
- if(m_pProcSM->CheckMonitorCar())
- {
- CMainFrame* mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- bool bControl = false;
- mainfrm->EditTreeItem(m_hTreeItem,bControl);
- }
- }
- void CTreeCtrlEx::OnUpdatePopCancelCurrMonitorCar(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- BOOL MenuEnable = m_pProcSM->m_bSysTemInit;
- pCmdUI->Enable(MenuEnable);
- }
- void CTreeCtrlEx::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
- {
- CTreeCtrl::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
-
- // TODO: Add your message handler code here
- BOOL MenuEnable = m_pProcSM->m_bSysTemInit;
- CMainFrame *pFrame = (CMainFrame *)AfxGetApp()->m_pMainWnd;
- if(!bSysMenu)
- {
- if (MenuEnable)
- {
- pPopupMenu->EnableMenuItem(0, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(1, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(2, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(3, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(4, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(5, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(6, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(7, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(8, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(6, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(10, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(11, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(12, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(13, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(14, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(15, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(16, MF_BYPOSITION | MF_ENABLED);
- pPopupMenu->EnableMenuItem(17, MF_BYPOSITION | MF_ENABLED);
- }
- else
- {
- pPopupMenu->EnableMenuItem(0, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(1, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(2, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(3, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(4, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(5, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(6, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(7, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(8, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(6, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(10, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(11, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(12, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(13, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(14, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(15, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(16, MF_BYPOSITION | MF_GRAYED);
- pPopupMenu->EnableMenuItem(17, MF_BYPOSITION | MF_GRAYED);
- }
- }
- }