GpsSCView.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:30k
- // GpsSCView.cpp : implementation of the CGpsSCView class
- //
- #include "stdafx.h"
- #include "GpsSC.h"
- #include "MainFrm.h"
- #include "GpsSCDoc.h"
- #include "GpsSCView.h"
- #include "ComUserDlg.h"
- #include "FindMessageDlg.h"
- #include "TreeCtrlEx.h"
- #include "VehicleMessageSet.h"
- #include "ClientinfoSet.h"
- #include "ToolTipWnd.h"
- #include "ListCtrlEx.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CGpsSCView
- extern CGpsSCApp theApp;
- IMPLEMENT_DYNCREATE(CGpsSCView, CScrollView)
- BEGIN_MESSAGE_MAP(CGpsSCView, CScrollView)
- //{{AFX_MSG_MAP(CGpsSCView)
- ON_MESSAGE(WM_COMMNOTIFY,OnCommNotify)
- ON_COMMAND(ID_TEST, OnTest)
- ON_UPDATE_COMMAND_UI(ID_TEST, OnUpdateTest)
- ON_UPDATE_COMMAND_UI(ID_SETJKNUMBER, OnUpdateSetjknumber)
- ON_COMMAND(ID_SINULATEDRIVER, OnSinulatedriver)
- ON_UPDATE_COMMAND_UI(ID_SINULATEDRIVER, OnUpdateSinulatedriver)
- ON_COMMAND(ID_CCONNET_COMM, OnCconnetComm)
- ON_COMMAND(ID_REFRESH, OnRefresh)
- ON_UPDATE_COMMAND_UI(ID_REFRESH, OnUpdateRefresh)
- ON_WM_MOUSEMOVE()
- ON_WM_TIMER()
- ON_COMMAND(ID_MZOOM_DOWN, OnMzoomDown)
- ON_UPDATE_COMMAND_UI(ID_MZOOM_DOWN, OnUpdateMzoomDown)
- ON_COMMAND(ID_MZOOM_UP, OnMzoomUp)
- ON_UPDATE_COMMAND_UI(ID_MZOOM_UP, OnUpdateMzoomUp)
- ON_COMMAND(ID_OPENLOCK, OnOpenlock)
- ON_COMMAND(ID_GETVEHICLEPOSITION, OnGetvehicleposition)
- ON_COMMAND(ID_SETLOCK, OnSetlock)
- ON_COMMAND(ID_SHUTOIL, OnShutoil)
- ON_COMMAND(ID_SETPASSWORD, OnSetpassword)
- ON_COMMAND(ID_SENDNORMALSM, OnSendnormalsm)
- ON_COMMAND(ID_SENDINFOTOGROUP, OnSendinfotogroup)
- ON_COMMAND(ID_SELECTTYPE, OnSelectUserType)
- ON_COMMAND(ID_AUTOMONITOR, OnAutomonitor)
- ON_COMMAND(ID_GETHELP, OnGethelp)
- ON_COMMAND(ID_MDISP_SIGN_POINT, OnMdispSignPoint)
- ON_UPDATE_COMMAND_UI(ID_MDISP_SIGN_POINT, OnUpdateMdispSignPoint)
- ON_COMMAND(ID_MSEARCH_SIGN_BY_REGION, OnMsearchSignByRegion)
- ON_UPDATE_COMMAND_UI(ID_MSEARCH_SIGN_BY_REGION, OnUpdateMsearchSignByRegion)
- ON_COMMAND(ID_MSEARCH_BEST_ROAD, OnMsearchBestRoad)
- ON_UPDATE_COMMAND_UI(ID_MSEARCH_BEST_ROAD, OnUpdateMsearchBestRoad)
- ON_COMMAND(ID_FINDMESSAGE, OnFindmessage)
- ON_UPDATE_COMMAND_UI(ID_AUTOMONITOR, OnUpdateAutomonitor)
- ON_WM_LBUTTONDOWN()
- ON_UPDATE_COMMAND_UI(ID_GETVEHICLEPOSITION, OnUpdateGetvehicleposition)
- ON_UPDATE_COMMAND_UI(ID_SETLOCK, OnUpdateSetlock)
- ON_UPDATE_COMMAND_UI(ID_SHUTOIL, OnUpdateShutoil)
- ON_UPDATE_COMMAND_UI(ID_GETHELP, OnUpdateGethelp)
- ON_UPDATE_COMMAND_UI(ID_OPENLOCK, OnUpdateOpenlock)
- ON_UPDATE_COMMAND_UI(ID_SENDNORMALSM, OnUpdateSendnormalsm)
- ON_UPDATE_COMMAND_UI(ID_SENDINFOTOGROUP, OnUpdateSendinfotogroup)
- ON_UPDATE_COMMAND_UI(ID_SELECTTYPE, OnUpdateSelecttype)
- ON_UPDATE_COMMAND_UI(ID_CHANGEUSERPASSWORD, OnUpdateChangeuserpassword)
- ON_UPDATE_COMMAND_UI(ID_SETPASSWORD, OnUpdateSetpassword)
- ON_COMMAND(ID_CDISCONNET_COMM, OnCdisconnetComm)
- ON_UPDATE_COMMAND_UI(ID_CDISCONNET_COMM, OnUpdateCdisconnetComm)
- ON_COMMAND(ID_CANCELAUTOMONITOR, OnCancelautomonitor)
- ON_UPDATE_COMMAND_UI(ID_CANCELAUTOMONITOR, OnUpdateCancelautomonitor)
- ON_WM_VSCROLL()
- ON_WM_HSCROLL()
- ON_WM_LBUTTONUP()
- ON_COMMAND(ID_POP_FRESH, OnPopFresh)
- ON_UPDATE_COMMAND_UI(ID_POP_FRESH, OnUpdatePopFresh)
- ON_WM_RBUTTONDOWN()
- ON_COMMAND(ID_MSEARCH_SIGN, OnMsearchSign)
- ON_UPDATE_COMMAND_UI(ID_MSEARCH_SIGN, OnUpdateMsearchSign)
- ON_WM_ERASEBKGND()
- ON_COMMAND(ID_CCONNECT_COM, OnCconnectCom)
- ON_UPDATE_COMMAND_UI(ID_CCONNECT_COM, OnUpdateCconnectCom)
- ON_COMMAND(ID_CANCEL_CURR_MONITOR_CAR, OnCancelCurrMonitorCar)
- ON_UPDATE_COMMAND_UI(ID_CANCEL_CURR_MONITOR_CAR, OnUpdateCancelCurrMonitorCar)
- ON_COMMAND(ID_SET_CURR_MONITOR_CAR, OnSetCurrMonitorCar)
- ON_UPDATE_COMMAND_UI(ID_SET_CURR_MONITOR_CAR, OnUpdateSetCurrMonitorCar)
- ON_UPDATE_COMMAND_UI(ID_CCONNET_COMM, OnUpdateCconnetComm)
- //}}AFX_MSG_MAP
-
- // Standard printing commands
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CGpsSCView construction/destruction
- CGpsSCView::CGpsSCView()
- {
- // TODO: add construction code here
- m_bSocketConnect = FALSE;
- password = FALSE;
- flag_usertype = TRUE;
- m_bDispSignPoint = false;
- m_bDispSignPic = false;
- m_bSearchBestRoad = false;
- m_bDispBusRoad = false;
- m_bSearchSignbyRegion = false;
- m_bMapIsDrawed = false;
- m_bLButtomDown = false;
- m_bMoveFatMap = false;
- m_pRBDownPoint.x = 0;
- m_pRBDownPoint.y = 0;
- m_nVMove = 0;
- m_nHMove = 0;
- m_DC.DeleteDC();
- }
- CGpsSCView::~CGpsSCView()
- {
- if(m_bMapIsDrawed) {
- m_DC.DeleteDC();
- }
- }
- BOOL CGpsSCView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CScrollView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CGpsSCView drawing
- void CGpsSCView::OnDraw(CDC* pDC)
- {
- CGpsSCDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- DrawMap(pDC);
- if(m_bDispSignPoint) m_cDrawMap.DrawSignLib(pDC);
- if(m_bSearchBestRoad) m_cDrawMap.DrawBetweenBRCrossLine(pDC,&m_cDrawMap.mSaveBRList);
- if(m_bSearchSignbyRegion) m_cDrawMap.DrawOneSignPoint(pDC);
- m_cDrawMap.DrawGpsCar(pDC,0.0);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CGpsSCView diagnostics
- #ifdef _DEBUG
- void CGpsSCView::AssertValid() const
- {
- CScrollView::AssertValid();
- }
- void CGpsSCView::Dump(CDumpContext& dc) const
- {
- CScrollView::Dump(dc);
- }
- CGpsSCDoc* CGpsSCView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGpsSCDoc)));
- return (CGpsSCDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CGpsSCView message handlers
- LRESULT CGpsSCView::OnCommNotify(WPARAM wParam, LPARAM lParam)
- {
- CGpsSCDoc *pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(!pDoc->m_bConnected || (wParam & EV_RXCHAR)!=EV_RXCHAR)
- {
- SetEvent(pDoc->m_hPostMsgEvent); //允许发送下一个WM_COMMNOTIFY消息
- return 0L;
- }
- CProcSM processSM;
- processSM.ReadComPort(wParam,pDoc);
- SetEvent(pDoc->m_hPostMsgEvent); //允许发送下一个WM_COMMNOTIFY消息
- return 0L;
- }
- void CGpsSCView::DrawMap(CDC *pDC)
- {
- // SetScrollSizes(MM_TEXT, CSize((int)Wnd_Max_X,(int)Wnd_Max_Y));
- CRect client;
- CRect rect;
- // pDC->GetClipBox(client); //检取无效区
- // GetClientRect(rect); //检取整个客户区
- if((m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_X == 0) || (m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_Y == 0)) {
- m_cDrawMap.RefreshMapWnd();
- }
- if(!m_bMapIsDrawed) {
- CBitmap bitmap;
- CBitmap *pOldBitmap;
- m_DC.DeleteDC();
- SetScrollPos(SB_HORZ,0,TRUE);
- SetScrollPos(SB_VERT,0,TRUE);
- rect.top = 0;
- rect.left = 0;
- rect.bottom = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_Y;
- rect.right = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_X;
- client.top = 0;
- client.left = 0;
- client.bottom = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_Y;
- client.right = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_X;
- if(m_DC.CreateCompatibleDC(pDC)) { //创建一个与pDC兼容的内存设备环境
- //创建一与pDC兼容的位图,大小为整个客户区
- if(bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height())) {
- OnPrepareDC(&m_DC,NULL); //使dc与pDC具有同样的映射关系
- pOldBitmap=m_DC.SelectObject(&bitmap); //将位图选入内存环境
- m_DC.SelectClipRgn(NULL); //使dc的整个客户区都成无效区
- m_DC.IntersectClipRect(client); //再"与上"检取的无效区,使内存环境与pDC检取的无效区相等
- }
- }
- CBrush brush;
- if(!brush.CreateSolidBrush(RGB(255,255,255))) {
- return;
- }
- brush.UnrealizeObject();
- m_DC.FillRect(client,&brush); //将dc的作图区刷新成背景色
- m_cDrawMap.DrawFatMap(&m_DC);
- bitmap.DeleteObject();
- pOldBitmap->DeleteObject();
- m_bMapIsDrawed = true;
- }
- pDC->GetClipBox(client); //检取无效区
- GetClientRect(rect); //检取整个客户区
- //移动滚动条
- MoveScroll();
- //拷贝到窗口裁减区
- pDC->BitBlt(client.left,client.top,client.Width(),client.Height(),&m_DC,client.left,client.top,SRCCOPY); //将内存裁减区的位图
- }
- void CGpsSCView::OnTest()
- {
- // TODO: Add your command handler code here
- CProcSM sm;
- CString str;
- str = "8F6653F7003A0030003700340039000D002276D163A7002263074EE45DF27ECF6267884C0021"; //监控指令已经执行!
- // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330030000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A0030"; //正常信息
- // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330031000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A0030"; //正常信息
- // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330031000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A0037";
- // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330032000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A00310031";
- AfxMessageBox(sm.UnicodeStr2AnsiStr(str));
- }
- void CGpsSCView::OnUpdateTest(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- BOOL MenuEnable = FALSE;
- pCmdUI->Enable(MenuEnable);
- }
- ///////////////////////////////////////////////////////////////////
- //向汽车发监控命令
- ///////////////////////////////////////////////////////////////////
- void CGpsSCView::OnUpdateSetjknumber(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- }
- void CGpsSCView::OnInitialUpdate()
- {
- CScrollView::OnInitialUpdate();
- // TODO: Add your specialized code here and/or call the base class
- m_ToolTip.Create(this);
- m_bDrawMap = FALSE;
- CSize sizeTotal;
- sizeTotal.cx = sizeTotal.cy = 100;
- SetScrollSizes(MM_TEXT, sizeTotal);
- CGpsSCDoc *pDoc = GetDocument();
- procSM.SetDocPointer(pDoc);
- m_pDoc = pDoc;
- //开始写线程
- procSM.BeginThread();
- ((CMainFrame*)AfxGetApp()->m_pMainWnd)->m_wndListCtrl.GetViewPoint(this);
- m_cDrawMap.GetView(this);
- SendGXGY("113.06.55rn","23.01.01rn","","",1); //佛山
- // SendGXGY("114.07.25rn","22.33.21rn","","",1); //深圳
- // SendGXGY("113.06.46rn","22.34.00rn","","",1); //深圳
- ((CMainFrame*)AfxGetApp()->m_pMainWnd)->m_wndTree1.Init(&procSM);
- ((CMainFrame*)AfxGetApp()->m_pMainWnd)->m_wndTree2.Init(&procSM);
- SetTimer(1,100,NULL);
- }
- //设定车主电话
- void CGpsSCView::OnSinulatedriver()
- {
- // TODO: Add your command handler code here
- procSM.SimulatorDriver();
- }
- void CGpsSCView::OnUpdateSinulatedriver(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnCconnetComm()
- {
- // TODO: Add your command handler code here
- m_pDoc = GetDocument();
- if(m_pDoc->OnConnetComm())
- procSM.SystermInite(this);
- CClientinfoSet clientinfoSet;
- CVehicleMessageSet messageSet;
- try
- {
- if(!clientinfoSet.IsOpen())
- clientinfoSet.Open();
- if(!messageSet.IsOpen())
- messageSet.Open();
- }
- catch(CDBException *Exp)
- {
- AfxMessageBox(Exp->m_strError);
- }
- }
- void CGpsSCView::OnRefresh()
- {
- // TODO: Add your command handler code here
- m_cDrawMap.ClearSaveInvalidRectColor();
- m_cDrawMap.ClearPointList(&m_cDrawMap.mSaveRecePointList);
- m_bSearchSignbyRegion = false;
- CGpsSCDoc *pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->UpdateAllViews(NULL);
- }
- void CGpsSCView::OnUpdateRefresh(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- }
- //get the gx and gy and convert it
- void CGpsSCView::SendGXGY(CString strGX,CString strGY,CString strVehicleNO,CString strTelNumber,BYTE IsSimulate)
- {
- if(!procSM.CheckVehicleMonitorNow(strVehicleNO)) return; //检测车辆是否已被监控
- #if 0
- if((!procSM.m_sCurrMonitorCar.IsEmpty()) && (procSM.m_sCurrMonitorCar != strVehicleNO)) return;
- // if(procSM.m_sGetPositionCar == strVehicleNO) {
- // procSM.m_sGetPositionCar.Empty();
- // }
- double gx,gy;
- CDC *pDC = GetDC();
- gx = CovertStdNE(strGX);
- gy = CovertStdNE(strGY);
- if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) {
- // pDC->DeleteDC();
- return;
- }
- if(IsSimulate) {
- m_cDrawMap.DrawGpsCar(pDC,0.0);
- }
- m_cDrawMap.GetCarXY(m_ny,m_ny);
- m_bDrawMap=TRUE;
- if(!m_cDrawMap.CheckMapIsChange(gx,gy)) {
- // pDC->DeleteDC();
- InvalidRect(gx,gy);
- return;
- }
- // pDC->DeleteDC();
- CGpsSCDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->UpdateAllViews(NULL);
- #else
- CRect MapRect;
- CDC *pDC = GetDC();
- double gx,gy;
- gx = CovertStdNE(strGX);
- gy = CovertStdNE(strGY);
- if(!m_cDrawMap.CheckMapIsChange(gx,gy)) {
- if(!IsSimulate) {
- if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) return;
- }
- m_cDrawMap.DrawGpsCar(pDC,0.0);
- m_cDrawMap.GetCarXY(m_nx,m_ny);
- m_bDrawMap = TRUE;
- return;
- }
- if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) return;
- if(IsSimulate) return;
- GetClientRect(MapRect);
- m_cDrawMap.RefreshMapWnd();
- if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) return;
- m_cDrawMap.DrawGpsCar(pDC,0.0);
- //获取车位置
- m_cDrawMap.GetCarXY(m_nx,m_ny);
- m_bDrawMap = TRUE;
- #endif
- }
- void CGpsSCView::InvalidRect(double gx, double gy)
- {
- long x,y;
- if(!m_cDrawMap.CalcNE2XY(gx,gy,x,y)) return;
- CRect lpRect;
- CPoint point = GetScrollPosition();
- long MidWidth = 100;
- x -= point.x;
- y -= point.y;
- lpRect.left = x - MidWidth - 20;
- lpRect.right = x + MidWidth + 20;
- lpRect.top = y - MidWidth;
- lpRect.bottom = y + MidWidth;
- CString str;
- str.Format("%d,%d,%d,%d",lpRect.left,lpRect.right,lpRect.top,lpRect.bottom);
- // StatusPrompt(str,0);
- // GetClientRect(lpRect);
- InvalidateRect(lpRect);
- }
- double CGpsSCView::CovertStdNE(CString StrNE)
- {
- CString Str,tmp;
- double dTmp;
- BYTE Len,i,chr;
- StrNE.Replace("r","");
- StrNE.Replace("n","");
- for(i = 0; i < StrNE.GetLength(); i ++) {
- chr = StrNE.GetAt(i);
- if(((chr < '0') || (chr > '9')) && (chr != '.')) {
- tmp = chr;
- StrNE.Replace(tmp,"");
- }
- }
- Len = StrNE.GetLength();
- Str = StrNE.Right(2);
- StrNE = StrNE.Left(Len - 2);
- StrNE.Replace(".","");
- dTmp = atof(Str);
- dTmp = dTmp / 60.0;
- return atof(StrNE) + dTmp;
- }
- void CGpsSCView::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- if(m_bLButtomDown) {
- SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_MOVE));
- }
- TrackDispData(point);
- CheckMousePointInList(point);
- MoveFatMap(point);
- CScrollView::OnMouseMove(nFlags, point);
- }
- void CGpsSCView::MoveFatMap(CPoint point)
- {
- int nScale=4;
- if(!m_bMoveFatMap) return;
-
- int nHMove, nVMove, i;
- nHMove = (point.y - m_pRBDownPoint.y) / nScale;
- nVMove = (point.x - m_pRBDownPoint.x) / nScale;
-
- m_nVMove+=point.x - m_pRBDownPoint.x;
- m_nHMove+=point.y - m_pRBDownPoint.y;
-
- if(nHMove > 0) {
- for(i = 0; i < nHMove; i++) {
- OnVScroll(SB_LINEUP, 0 ,NULL); //响应UP键
- }
- m_nHMove=0;
- }
- else{
- if(m_nHMove>=nScale){
- // OnVScroll(SB_LINEUP, 0 ,NULL); //响应UP键
- m_nHMove=0;
- }
- }
-
- if(nHMove < 0) {
- nHMove = -nHMove;
- for(i = 0; i < nHMove; i++) {
- OnVScroll(SB_LINEDOWN, 0 ,NULL); //响应DOWN键
- }
- m_nHMove=0;
- }
- else{
- if(m_nHMove<=-nScale){
- // OnVScroll(SB_LINEDOWN, 0 ,NULL); //响应DOWN键
- m_nHMove=0;
- }
- }
-
- if(nVMove > 0) {
- for(i = 0; i < nVMove; i++) {
- OnHScroll(SB_LINELEFT, 0 ,NULL); //响应LEFT键
- }
- m_nVMove=0;
- }
- else{
- if(m_nVMove>=nScale){
- // OnHScroll(SB_LINELEFT, 0 ,NULL); //响应LEFT键
- m_nVMove=0;
- }
- }
- if(nVMove < 0) {
- nVMove=-nVMove;
- for(i = 0; i < nVMove; i++) {
- OnHScroll(SB_LINERIGHT, 0 ,NULL); //响应RIGHT键
- }
- m_nVMove=0;
- }
- else{
- if(m_nVMove<=-nScale){
- // OnHScroll(SB_LINERIGHT, 0 ,NULL); //响应RIGHT键
- m_nVMove=0;
- }
- }
- m_pRBDownPoint = point;
- }
- /*************Set status prompt*************/
- void CGpsSCView::StatusPrompt(CString pmt,UINT uID)
- {
- CStatusBar* pStatus=(CStatusBar*)
- AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_VIEW_STATUS_BAR);
- ASSERT(pStatus);
- if(pStatus) {
- pStatus->SetPaneText(uID,pmt,TRUE);
- }
- }
- void CGpsSCView::CovertDFS(double LongNE,int *Angle,int *Minute,int *Second)
- {
- double dTmp;
- dTmp = LongNE;
- dTmp = dTmp / 100.0;
- *Angle = (int)(dTmp);
- dTmp = (dTmp - *Angle) * 100.0;
- *Minute = (int)(dTmp);
- *Second = (int)((dTmp - *Minute) * 60);
- }
- void CGpsSCView::TrackDispData(CPoint point)
- {
- CGpsPoint cGpsPoint;
- CString Prompt;
- int Angle1,Minute1,Second1,Angle2,Minute2,Second2;
- cGpsPoint.m_lx = point.x; cGpsPoint.m_ly = point.y;
- m_cDrawMap.CovertNEXY(&cGpsPoint, m_cDrawMap.m_cCurrMapInfo.CoeffXY_NE, false);
- CovertDFS(cGpsPoint.m_dgx,&Angle1,&Minute1,&Second1);
- CovertDFS(cGpsPoint.m_dgy,&Angle2,&Minute2,&Second2);
- Prompt.Format("(%d,%d);(%d°%02d′%02d″,%d°%02d′%02d″)",point.x,point.y,Angle1,Minute1,Second1,Angle2,Minute2,Second2);
- StatusPrompt(Prompt,1);
- }
- void CGpsSCView::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- #if 0
- CGpsSCDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CString SystemTitle;
- SystemTitle = m_cDrawMap.m_cCurrMapInfo.m_LinkFileName;
- pDoc->SetTitle(SystemTitle);
- #endif
- CScrollView::OnTimer(nIDEvent);
- }
- void CGpsSCView::OnMzoomDown()
- {
- // TODO: Add your command handler code here
- m_cDrawMap.ZoomDown();
- }
- void CGpsSCView::OnUpdateMzoomDown(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- }
- void CGpsSCView::OnMzoomUp()
- {
- // TODO: Add your command handler code here
- m_cDrawMap.ZoomUp();
- }
- void CGpsSCView::OnUpdateMzoomUp(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- }
- //开锁
- void CGpsSCView::OnOpenlock()
- {
- // TODO: Add your command handler code here
- procSM.OnOpenlock();
- }
- //取位置
- void CGpsSCView::OnGetvehicleposition()
- {
- // TODO: Add your command handler code here
- procSM.OnGetvehicleposition();
- }
- //上锁
- void CGpsSCView::OnSetlock()
- {
- // TODO: Add your command handler code here
- procSM.OnSetlock();
- }
- //断油
- void CGpsSCView::OnShutoil()
- {
- // TODO: Add your command handler code here
- procSM. OnShutoil();
- }
- void CGpsSCView::SetCommonUserTelNo(CString)
- {
- }
- //Host change his owen password
- void CGpsSCView::OnSetpassword()
- {
- procSM.HoseChangePassWord();
- }
- void CGpsSCView::OnSendnormalsm()
- {
- // TODO: Add your command handler code here
- AfxMessageBox("对不起! 此功能只提供给正式版用户!");
- }
- void CGpsSCView::OnSendinfotogroup()
- {
- // TODO: Add your command handler code here
- AfxMessageBox("对不起! 此功能只提供给正式用户!");
- }
- void CGpsSCView::OnSelectUserType()
- {
- // TODO: Add your command handler code here
- procSM.SelectUserType();
- if(procSM.m_nUserType==1)
- flag_usertype=FALSE;
- if(procSM.m_nUserType==0)
- flag_usertype=TRUE;
- }
- void CGpsSCView::OnAutomonitor()
- {
- // TODO: Add your command handler code here
- procSM.AutoMonitor();
- }
- void CGpsSCView::OnGethelp()
- {
- // TODO: Add your command handler code here
- procSM.GetHelp();
- }
- void CGpsSCView::OnShowconnetDlg()
- {
- // CGpsSCApp *vpsapp=NULL;
- /* {
- m_pDoc = GetDocument();
- if(m_pDoc->OnConnetComm())
- procSM.SystermInite(this);
- }*/
- }
- void CGpsSCView::OnMdispSignPoint()
- {
- // TODO: Add your command handler code here
- if(!m_bDispSignPoint) {
- if(!m_cDrawMap.ShowSignLib()) return;
- m_bDispSignPoint = true;
- }
- else {
- m_bDispSignPoint = false;
- }
- OnRefresh();
- }
- void CGpsSCView::OnUpdateMdispSignPoint(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- }
- void CGpsSCView::OnMsearchSignByRegion()
- {
- // TODO: Add your command handler code here
- m_bSearchSignbyRegion = true;
- m_cDrawMap.SearchSign();
- }
- void CGpsSCView::OnUpdateMsearchSignByRegion(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(theApp.m_bUserType);
- }
- void CGpsSCView::OnMsearchBestRoad()
- {
- // TODO: Add your command handler code here
- if(!m_bSearchBestRoad) {
- m_bSearchBestRoad = true;
- AfxMessageBox("请选择起点");
- }
- else {
- m_bSearchBestRoad = false;
- OnRefresh();
- }
- }
- void CGpsSCView::OnUpdateMsearchBestRoad(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(FALSE);
- }
- void CGpsSCView::OnFindmessage()
- {
- // TODO: Add your command handler code here
- CFindMessageDlg dlg;
- dlg.DoModal();
- }
- void CGpsSCView::OnUpdateAutomonitor(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- BOOL MenuEnable = procSM.m_bSysTemInit;
- // MenuEnable = MenuEnable && flag_usertype;
- pCmdUI->Enable(MenuEnable);
- }
- void CGpsSCView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- DrawMoveRect(point);
- if(m_bSearchBestRoad) m_cDrawMap.CalculateBRroadPath(point);
- m_bMoveFatMap = true;
- m_pRBDownPoint = point;
- CScrollView::OnLButtonDown(nFlags, point);
- }
- void CGpsSCView::DrawMoveRect(CPoint point)
- {
- if(!m_bLButtomDown) {
- SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_MOVE));
- m_bLButtomDown = true;
- }
- return;
- CRectTracker cRect;
- CPoint cPoint;
- cRect.m_rect.SetRect(10, 10, 300, 300);
- cRect.m_nStyle = CRectTracker::resizeInside | CRectTracker::dottedLine;
- cRect.TrackRubberBand(this,point);
- }
- void CGpsSCView::OnLButtonUp(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- if(m_bLButtomDown) {
- m_bLButtomDown = false;
- }
- m_bMoveFatMap = false;
- CScrollView::OnLButtonUp(nFlags, point);
- }
- void CGpsSCView::OnUpdateGetvehicleposition(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateSetlock(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateShutoil(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateGethelp(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateOpenlock(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateSendnormalsm(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateSendinfotogroup(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateSelecttype(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateChangeuserpassword(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnUpdateSetpassword(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnCconnectCom()
- {
- // TODO: Add your command handler code here
- CGpsSCDoc *pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- m_pDoc->OnConnetComm();
- procSM.m_bSysTemInit = FALSE;
- }
- void CGpsSCView::OnUpdateCconnectCom(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(!procSM.m_bSysTemInit);
- }
- void CGpsSCView::OnCdisconnetComm()
- {
- // TODO: Add your command handler code here
- CGpsSCDoc *pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->CloseConnection();
- procSM.m_bSysTemInit = FALSE;
- }
- void CGpsSCView::OnUpdateCdisconnetComm(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- LRESULT CGpsSCView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- // TODO: Add your specialized code here and/or call the base class
- switch(message)
- {
- case WM_MOUSEMOVE:
- {
- MSG msg;
- msg.hwnd=m_hWnd;
- msg.message=message;
- msg.wParam=wParam;
- msg.lParam=lParam;
- m_ToolTip.RelayEvent(&msg);
- }
- }
- return CScrollView::WindowProc(message, wParam, lParam);
- }
- BOOL CGpsSCView::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(m_ToolTip)
- m_ToolTip.RelayEvent(pMsg);
- m_ToolTip.SetTipBkColor(RGB(050,250,255));
- return CScrollView::PreTranslateMessage(pMsg);
- }
- void CGpsSCView::OnCancelautomonitor()
- {
- // TODO: Add your command handler code here
- procSM.CanceLautoMonitor();
- if(procSM.CheckMonitorCar())
- {
- CMainFrame* mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- bool bConctrol = false;
- mainfrm->EditTreeItem(bConctrol);
- }
- }
- void CGpsSCView::OnUpdateCancelautomonitor(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(procSM.m_bSysTemInit);
- }
- void CGpsSCView::CheckMousePointInList(CPoint point)
- {
- CMainFrame *pMainFrame = NULL;
- CString Str,Data("");
- int nListCount,i;
- // int j;
- double gx,gy;
- long x,y;
- pMainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
- nListCount = pMainFrame->m_wndListCtrl.GetItemCount();
- for(i = 0; i < nListCount; i++) {
- gx = CovertStdNE(pMainFrame->m_wndListCtrl.GetItemText(i,5));
- gy = CovertStdNE(pMainFrame->m_wndListCtrl.GetItemText(i,6));
- // for(j = 0; j < 7; j++) {
- Data="";
- Str.Format("%s,%c",pMainFrame->m_wndListCtrl.GetItemText(i,1),'n');
- Data += Str;
- Str.Format("%s,%c",pMainFrame->m_wndListCtrl.GetItemText(i,2),'n');
- Data += Str;
- Str.Format("%s,%c",pMainFrame->m_wndListCtrl.GetItemText(i,7),'n');
- Data += Str;
- Str.Format("%s",pMainFrame->m_wndListCtrl.GetItemText(i,9));
- Data += Str;
- // }
- m_cDrawMap.CalcNE2XY(gx,gy,x,y);
- if((abs(point.x - x) < 3) && (abs(point.y - y) < 3)) {
- m_ToolTip.AddTool(this,Data);
- m_ToolTip.Activate(TRUE);
- }
- }
- }
- //移动滚动条
- void CGpsSCView::MoveScroll()
- {
- int nx,ny;
- nx=ny=0;
- if((m_bDrawMap==TRUE)&&(m_cDrawMap.m_byZoomCoeffic>1))
- {
- SetScrollRange(SB_HORZ,0,430,TRUE);
- SetScrollRange(SB_VERT,0,260,TRUE);
- if(m_nx>430)
- nx = m_nx-430;
- if(m_ny>260)
- ny = m_ny-260;
- SetScrollPos(SB_HORZ,nx,TRUE);
- SetScrollPos(SB_VERT,ny,TRUE);
- }
- m_bDrawMap = FALSE;
- }
- void CGpsSCView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- // TODO: Add your message handler code here and/or call default
- m_bDrawMap = FALSE;
- CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
- }
- void CGpsSCView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- // TODO: Add your message handler code here and/or call default
- m_bDrawMap = FALSE;
- CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
- }
- void CGpsSCView::OnPopFresh()
- {
- // TODO: Add your command handler code here
- CGpsSCDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDoc->UpdateAllViews(NULL);
- }
- void CGpsSCView::OnUpdatePopFresh(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
-
- }
- void CGpsSCView::OnRButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- CMenu PopMenu,*pSubMenu;
- CRect lpRect;
- GetWindowRect(&lpRect);
- PopMenu.LoadMenu(IDR_POP_MENU);
- pSubMenu = PopMenu.GetSubMenu(1);
- pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
- point.x + lpRect.left,
- point.y + lpRect.top, AfxGetMainWnd(),NULL);
- pSubMenu = NULL;
- PopMenu.DestroyMenu();
- CScrollView::OnRButtonDown(nFlags, point);
- }
- void CGpsSCView::OnMsearchSign()
- {
- // TODO: Add your command handler code here
- m_bSearchSignbyRegion = true;
- m_cDrawMap.SearchSignByInput();
- }
- void CGpsSCView::OnUpdateMsearchSign(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
-
- }
- BOOL CGpsSCView::OnEraseBkgnd(CDC* pDC)
- {
- // TODO: Add your message handler code here and/or call default
- return FALSE;
- // return CScrollView::OnEraseBkgnd(pDC);
- }
- void CGpsSCView::OnCancelCurrMonitorCar()
- {
- // TODO: Add your command handler code here
- if(procSM.CheckMonitorCar())
- {
- CMainFrame* mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- bool bConctrol = false;
- mainfrm->EditTreeItem(bConctrol);
- }
- }
- void CGpsSCView::OnUpdateCancelCurrMonitorCar(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- BOOL MenuEnable = procSM.m_bSysTemInit;
- pCmdUI->Enable(MenuEnable);
- }
- void CGpsSCView::OnSetCurrMonitorCar()
- {
- // TODO: Add your command handler code here
- CClientinfoSet cSet;
- CString VehicleID,VehicleTel;
- CMainFrame* mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
- cSet.FindCarNumberAndPhone(str_GetTreeItemText,VehicleID,VehicleTel);
- procSM.SetMonitorCar(VehicleID);
- if(!procSM.CheckMonitorCar())
- {
- mainfrm->EditTreeItem();
- }
- }
- void CGpsSCView::OnUpdateSetCurrMonitorCar(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- BOOL MenuEnable = procSM.m_bSysTemInit;
- pCmdUI->Enable(MenuEnable);
- }
- void CGpsSCView::OnUpdateCconnetComm(CCmdUI* pCmdUI)
- {
- // TODO: Add your command update UI handler code here
- pCmdUI->Enable(theApp.m_bUserType);
- }