GpsSCView.cpp
上传用户:yffx2008
上传日期:2014-10-12
资源大小:12414k
文件大小:30k
源码类别:

交通/航空行业

开发平台:

Visual C++

  1.  // GpsSCView.cpp : implementation of the CGpsSCView class
  2. //
  3. #include "stdafx.h"
  4. #include "GpsSC.h"
  5. #include "MainFrm.h"
  6. #include "GpsSCDoc.h"
  7. #include "GpsSCView.h"
  8. #include "ComUserDlg.h"
  9. #include "FindMessageDlg.h"
  10. #include "TreeCtrlEx.h"
  11. #include "VehicleMessageSet.h"
  12. #include "ClientinfoSet.h"
  13. #include "ToolTipWnd.h"
  14. #include "ListCtrlEx.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CGpsSCView
  22. extern CGpsSCApp theApp;
  23. IMPLEMENT_DYNCREATE(CGpsSCView, CScrollView)
  24. BEGIN_MESSAGE_MAP(CGpsSCView, CScrollView)
  25. //{{AFX_MSG_MAP(CGpsSCView)
  26. ON_MESSAGE(WM_COMMNOTIFY,OnCommNotify)
  27. ON_COMMAND(ID_TEST, OnTest)
  28. ON_UPDATE_COMMAND_UI(ID_TEST, OnUpdateTest)
  29. ON_UPDATE_COMMAND_UI(ID_SETJKNUMBER, OnUpdateSetjknumber)
  30. ON_COMMAND(ID_SINULATEDRIVER, OnSinulatedriver)
  31. ON_UPDATE_COMMAND_UI(ID_SINULATEDRIVER, OnUpdateSinulatedriver)
  32. ON_COMMAND(ID_CCONNET_COMM, OnCconnetComm)
  33. ON_COMMAND(ID_REFRESH, OnRefresh)
  34. ON_UPDATE_COMMAND_UI(ID_REFRESH, OnUpdateRefresh)
  35. ON_WM_MOUSEMOVE()
  36. ON_WM_TIMER()
  37. ON_COMMAND(ID_MZOOM_DOWN, OnMzoomDown)
  38. ON_UPDATE_COMMAND_UI(ID_MZOOM_DOWN, OnUpdateMzoomDown)
  39. ON_COMMAND(ID_MZOOM_UP, OnMzoomUp)
  40. ON_UPDATE_COMMAND_UI(ID_MZOOM_UP, OnUpdateMzoomUp)
  41. ON_COMMAND(ID_OPENLOCK, OnOpenlock)
  42. ON_COMMAND(ID_GETVEHICLEPOSITION, OnGetvehicleposition)
  43. ON_COMMAND(ID_SETLOCK, OnSetlock)
  44. ON_COMMAND(ID_SHUTOIL, OnShutoil)
  45. ON_COMMAND(ID_SETPASSWORD, OnSetpassword)
  46. ON_COMMAND(ID_SENDNORMALSM, OnSendnormalsm)
  47. ON_COMMAND(ID_SENDINFOTOGROUP, OnSendinfotogroup)
  48. ON_COMMAND(ID_SELECTTYPE, OnSelectUserType)
  49. ON_COMMAND(ID_AUTOMONITOR, OnAutomonitor)
  50. ON_COMMAND(ID_GETHELP, OnGethelp)
  51. ON_COMMAND(ID_MDISP_SIGN_POINT, OnMdispSignPoint)
  52. ON_UPDATE_COMMAND_UI(ID_MDISP_SIGN_POINT, OnUpdateMdispSignPoint)
  53. ON_COMMAND(ID_MSEARCH_SIGN_BY_REGION, OnMsearchSignByRegion)
  54. ON_UPDATE_COMMAND_UI(ID_MSEARCH_SIGN_BY_REGION, OnUpdateMsearchSignByRegion)
  55. ON_COMMAND(ID_MSEARCH_BEST_ROAD, OnMsearchBestRoad)
  56. ON_UPDATE_COMMAND_UI(ID_MSEARCH_BEST_ROAD, OnUpdateMsearchBestRoad)
  57. ON_COMMAND(ID_FINDMESSAGE, OnFindmessage)
  58. ON_UPDATE_COMMAND_UI(ID_AUTOMONITOR, OnUpdateAutomonitor)
  59. ON_WM_LBUTTONDOWN()
  60. ON_UPDATE_COMMAND_UI(ID_GETVEHICLEPOSITION, OnUpdateGetvehicleposition)
  61. ON_UPDATE_COMMAND_UI(ID_SETLOCK, OnUpdateSetlock)
  62. ON_UPDATE_COMMAND_UI(ID_SHUTOIL, OnUpdateShutoil)
  63. ON_UPDATE_COMMAND_UI(ID_GETHELP, OnUpdateGethelp)
  64. ON_UPDATE_COMMAND_UI(ID_OPENLOCK, OnUpdateOpenlock)
  65. ON_UPDATE_COMMAND_UI(ID_SENDNORMALSM, OnUpdateSendnormalsm)
  66. ON_UPDATE_COMMAND_UI(ID_SENDINFOTOGROUP, OnUpdateSendinfotogroup)
  67. ON_UPDATE_COMMAND_UI(ID_SELECTTYPE, OnUpdateSelecttype)
  68. ON_UPDATE_COMMAND_UI(ID_CHANGEUSERPASSWORD, OnUpdateChangeuserpassword)
  69. ON_UPDATE_COMMAND_UI(ID_SETPASSWORD, OnUpdateSetpassword)
  70. ON_COMMAND(ID_CDISCONNET_COMM, OnCdisconnetComm)
  71. ON_UPDATE_COMMAND_UI(ID_CDISCONNET_COMM, OnUpdateCdisconnetComm)
  72. ON_COMMAND(ID_CANCELAUTOMONITOR, OnCancelautomonitor)
  73. ON_UPDATE_COMMAND_UI(ID_CANCELAUTOMONITOR, OnUpdateCancelautomonitor)
  74. ON_WM_VSCROLL()
  75. ON_WM_HSCROLL()
  76. ON_WM_LBUTTONUP()
  77. ON_COMMAND(ID_POP_FRESH, OnPopFresh)
  78. ON_UPDATE_COMMAND_UI(ID_POP_FRESH, OnUpdatePopFresh)
  79. ON_WM_RBUTTONDOWN()
  80. ON_COMMAND(ID_MSEARCH_SIGN, OnMsearchSign)
  81. ON_UPDATE_COMMAND_UI(ID_MSEARCH_SIGN, OnUpdateMsearchSign)
  82. ON_WM_ERASEBKGND()
  83. ON_COMMAND(ID_CCONNECT_COM, OnCconnectCom)
  84. ON_UPDATE_COMMAND_UI(ID_CCONNECT_COM, OnUpdateCconnectCom)
  85. ON_COMMAND(ID_CANCEL_CURR_MONITOR_CAR, OnCancelCurrMonitorCar)
  86. ON_UPDATE_COMMAND_UI(ID_CANCEL_CURR_MONITOR_CAR, OnUpdateCancelCurrMonitorCar)
  87. ON_COMMAND(ID_SET_CURR_MONITOR_CAR, OnSetCurrMonitorCar)
  88. ON_UPDATE_COMMAND_UI(ID_SET_CURR_MONITOR_CAR, OnUpdateSetCurrMonitorCar)
  89. ON_UPDATE_COMMAND_UI(ID_CCONNET_COMM, OnUpdateCconnetComm)
  90. //}}AFX_MSG_MAP
  91. // Standard printing commands
  92. END_MESSAGE_MAP()
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CGpsSCView construction/destruction
  95. CGpsSCView::CGpsSCView()
  96. {
  97. // TODO: add construction code here
  98. m_bSocketConnect = FALSE;
  99. password = FALSE;
  100. flag_usertype = TRUE;
  101. m_bDispSignPoint = false;
  102. m_bDispSignPic = false;
  103. m_bSearchBestRoad = false;
  104. m_bDispBusRoad = false;
  105. m_bSearchSignbyRegion = false;
  106. m_bMapIsDrawed = false;
  107. m_bLButtomDown = false;
  108. m_bMoveFatMap = false;
  109. m_pRBDownPoint.x = 0;
  110. m_pRBDownPoint.y = 0;
  111. m_nVMove = 0;
  112. m_nHMove = 0;
  113. m_DC.DeleteDC();
  114. }
  115. CGpsSCView::~CGpsSCView()
  116. {
  117. if(m_bMapIsDrawed) {
  118. m_DC.DeleteDC();
  119. }
  120. }
  121. BOOL CGpsSCView::PreCreateWindow(CREATESTRUCT& cs)
  122. {
  123. // TODO: Modify the Window class or styles here by modifying
  124. //  the CREATESTRUCT cs
  125. return CScrollView::PreCreateWindow(cs);
  126. }
  127. /////////////////////////////////////////////////////////////////////////////
  128. // CGpsSCView drawing
  129. void CGpsSCView::OnDraw(CDC* pDC)
  130. {
  131. CGpsSCDoc* pDoc = GetDocument();
  132. ASSERT_VALID(pDoc);
  133. // TODO: add draw code for native data here
  134. DrawMap(pDC);
  135. if(m_bDispSignPoint) m_cDrawMap.DrawSignLib(pDC);
  136. if(m_bSearchBestRoad) m_cDrawMap.DrawBetweenBRCrossLine(pDC,&m_cDrawMap.mSaveBRList);
  137. if(m_bSearchSignbyRegion) m_cDrawMap.DrawOneSignPoint(pDC);
  138. m_cDrawMap.DrawGpsCar(pDC,0.0);
  139. }
  140. /////////////////////////////////////////////////////////////////////////////
  141. // CGpsSCView diagnostics
  142. #ifdef _DEBUG
  143. void CGpsSCView::AssertValid() const
  144. {
  145. CScrollView::AssertValid();
  146. }
  147. void CGpsSCView::Dump(CDumpContext& dc) const
  148. {
  149. CScrollView::Dump(dc);
  150. }
  151. CGpsSCDoc* CGpsSCView::GetDocument() // non-debug version is inline
  152. {
  153. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGpsSCDoc)));
  154. return (CGpsSCDoc*)m_pDocument;
  155. }
  156. #endif //_DEBUG
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CGpsSCView message handlers
  159. LRESULT CGpsSCView::OnCommNotify(WPARAM wParam, LPARAM lParam)
  160. {
  161. CGpsSCDoc *pDoc = GetDocument();
  162. ASSERT_VALID(pDoc);
  163. if(!pDoc->m_bConnected || (wParam & EV_RXCHAR)!=EV_RXCHAR) 
  164. {
  165. SetEvent(pDoc->m_hPostMsgEvent); //允许发送下一个WM_COMMNOTIFY消息
  166. return 0L;
  167. }
  168. CProcSM processSM;
  169. processSM.ReadComPort(wParam,pDoc);
  170. SetEvent(pDoc->m_hPostMsgEvent); //允许发送下一个WM_COMMNOTIFY消息
  171. return 0L;
  172. }
  173. void CGpsSCView::DrawMap(CDC *pDC)
  174. {
  175. // SetScrollSizes(MM_TEXT, CSize((int)Wnd_Max_X,(int)Wnd_Max_Y));
  176. CRect client; 
  177. CRect rect; 
  178. // pDC->GetClipBox(client); //检取无效区
  179. // GetClientRect(rect); //检取整个客户区 
  180. if((m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_X == 0) || (m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_Y == 0)) {
  181. m_cDrawMap.RefreshMapWnd();
  182. }
  183. if(!m_bMapIsDrawed) {
  184. CBitmap bitmap; 
  185. CBitmap *pOldBitmap; 
  186. m_DC.DeleteDC();
  187. SetScrollPos(SB_HORZ,0,TRUE);
  188. SetScrollPos(SB_VERT,0,TRUE);
  189. rect.top = 0;
  190. rect.left = 0;
  191. rect.bottom = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_Y;
  192. rect.right = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_X;
  193. client.top = 0;
  194. client.left = 0;
  195. client.bottom = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_Y;
  196. client.right = m_cDrawMap.m_cCurrMapInfo.m_lWnd_Max_X;
  197. if(m_DC.CreateCompatibleDC(pDC)) { //创建一个与pDC兼容的内存设备环境 
  198. //创建一与pDC兼容的位图,大小为整个客户区 
  199. if(bitmap.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height())) {
  200. OnPrepareDC(&m_DC,NULL); //使dc与pDC具有同样的映射关系 
  201. pOldBitmap=m_DC.SelectObject(&bitmap); //将位图选入内存环境 
  202. m_DC.SelectClipRgn(NULL); //使dc的整个客户区都成无效区 
  203. m_DC.IntersectClipRect(client); //再"与上"检取的无效区,使内存环境与pDC检取的无效区相等 
  204. CBrush brush; 
  205. if(!brush.CreateSolidBrush(RGB(255,255,255))) {
  206. return; 
  207. }
  208. brush.UnrealizeObject();
  209. m_DC.FillRect(client,&brush); //将dc的作图区刷新成背景色
  210. m_cDrawMap.DrawFatMap(&m_DC);
  211. bitmap.DeleteObject();
  212. pOldBitmap->DeleteObject();
  213. m_bMapIsDrawed = true;
  214. }
  215. pDC->GetClipBox(client); //检取无效区
  216. GetClientRect(rect); //检取整个客户区 
  217. //移动滚动条
  218. MoveScroll();
  219. //拷贝到窗口裁减区
  220. pDC->BitBlt(client.left,client.top,client.Width(),client.Height(),&m_DC,client.left,client.top,SRCCOPY); //将内存裁减区的位图 
  221. }
  222. void CGpsSCView::OnTest() 
  223. {
  224. // TODO: Add your command handler code here
  225. CProcSM sm;
  226. CString str;
  227. str = "8F6653F7003A0030003700340039000D002276D163A7002263074EE45DF27ECF6267884C0021"; //监控指令已经执行!
  228. // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330030000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A0030"; //正常信息
  229. // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330031000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A0030"; //正常信息
  230. // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330031000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A0037";
  231. // str = "8F6653F7003A0030003700340039000D8F6651B5003A89E39664963276D7000D4F4D7F6E003A6DF1573357CE533A6C344E0A4E5056ED000D7ECF5EA6003A003100310034002E00300031002E00330032000D7EAC5EA6003A00320032002E00330032002E00330034000D8F66901F003A00310031";
  232. AfxMessageBox(sm.UnicodeStr2AnsiStr(str));
  233. }
  234. void CGpsSCView::OnUpdateTest(CCmdUI* pCmdUI) 
  235. {
  236. // TODO: Add your command update UI handler code here
  237. BOOL MenuEnable = FALSE;
  238. pCmdUI->Enable(MenuEnable);
  239. }
  240. ///////////////////////////////////////////////////////////////////
  241. //向汽车发监控命令
  242. ///////////////////////////////////////////////////////////////////
  243. void CGpsSCView::OnUpdateSetjknumber(CCmdUI* pCmdUI)
  244. {
  245. // TODO: Add your command update UI handler code here
  246. }
  247. void CGpsSCView::OnInitialUpdate()
  248. {
  249. CScrollView::OnInitialUpdate();
  250. // TODO: Add your specialized code here and/or call the base class
  251. m_ToolTip.Create(this);
  252. m_bDrawMap = FALSE;
  253. CSize sizeTotal;
  254.     sizeTotal.cx = sizeTotal.cy = 100;
  255.     SetScrollSizes(MM_TEXT, sizeTotal);
  256. CGpsSCDoc *pDoc = GetDocument();
  257. procSM.SetDocPointer(pDoc);
  258. m_pDoc = pDoc;
  259. //开始写线程
  260. procSM.BeginThread();
  261. ((CMainFrame*)AfxGetApp()->m_pMainWnd)->m_wndListCtrl.GetViewPoint(this);
  262. m_cDrawMap.GetView(this);
  263. SendGXGY("113.06.55rn","23.01.01rn","","",1); //佛山
  264. // SendGXGY("114.07.25rn","22.33.21rn","","",1); //深圳
  265. // SendGXGY("113.06.46rn","22.34.00rn","","",1); //深圳
  266. ((CMainFrame*)AfxGetApp()->m_pMainWnd)->m_wndTree1.Init(&procSM);
  267. ((CMainFrame*)AfxGetApp()->m_pMainWnd)->m_wndTree2.Init(&procSM);
  268. SetTimer(1,100,NULL);
  269. }
  270. //设定车主电话
  271. void CGpsSCView::OnSinulatedriver()
  272. {
  273. // TODO: Add your command handler code here
  274. procSM.SimulatorDriver();
  275. }
  276. void CGpsSCView::OnUpdateSinulatedriver(CCmdUI* pCmdUI)
  277. {
  278. // TODO: Add your command update UI handler code here
  279. pCmdUI->Enable(procSM.m_bSysTemInit);
  280. }
  281. void CGpsSCView::OnCconnetComm()
  282. {
  283. // TODO: Add your command handler code here
  284. m_pDoc = GetDocument();
  285. if(m_pDoc->OnConnetComm())
  286. procSM.SystermInite(this);
  287. CClientinfoSet clientinfoSet;
  288. CVehicleMessageSet messageSet;
  289. try
  290. {
  291. if(!clientinfoSet.IsOpen())
  292. clientinfoSet.Open();
  293. if(!messageSet.IsOpen())
  294. messageSet.Open();
  295. }
  296. catch(CDBException *Exp)
  297. {
  298. AfxMessageBox(Exp->m_strError);
  299. }
  300. }
  301. void CGpsSCView::OnRefresh() 
  302. {
  303. // TODO: Add your command handler code here
  304. m_cDrawMap.ClearSaveInvalidRectColor();
  305. m_cDrawMap.ClearPointList(&m_cDrawMap.mSaveRecePointList);
  306. m_bSearchSignbyRegion = false;
  307. CGpsSCDoc *pDoc = GetDocument();
  308. ASSERT_VALID(pDoc);
  309. pDoc->UpdateAllViews(NULL);
  310. }
  311. void CGpsSCView::OnUpdateRefresh(CCmdUI* pCmdUI) 
  312. {
  313. // TODO: Add your command update UI handler code here
  314. }
  315. //get the gx and gy and convert it
  316. void CGpsSCView::SendGXGY(CString strGX,CString strGY,CString strVehicleNO,CString strTelNumber,BYTE IsSimulate)
  317. {
  318. if(!procSM.CheckVehicleMonitorNow(strVehicleNO)) return; //检测车辆是否已被监控
  319. #if 0
  320. if((!procSM.m_sCurrMonitorCar.IsEmpty()) && (procSM.m_sCurrMonitorCar != strVehicleNO)) return;
  321. // if(procSM.m_sGetPositionCar == strVehicleNO) {
  322. // procSM.m_sGetPositionCar.Empty();
  323. // }
  324. double gx,gy;
  325. CDC *pDC = GetDC();
  326. gx = CovertStdNE(strGX);
  327. gy = CovertStdNE(strGY);
  328. if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) {
  329. // pDC->DeleteDC();
  330. return;
  331. }
  332. if(IsSimulate) {
  333. m_cDrawMap.DrawGpsCar(pDC,0.0);
  334. }
  335. m_cDrawMap.GetCarXY(m_ny,m_ny);
  336. m_bDrawMap=TRUE;
  337. if(!m_cDrawMap.CheckMapIsChange(gx,gy)) {
  338. // pDC->DeleteDC();
  339. InvalidRect(gx,gy);
  340. return;
  341. }
  342. // pDC->DeleteDC();
  343. CGpsSCDoc* pDoc = GetDocument();
  344. ASSERT_VALID(pDoc);
  345. pDoc->UpdateAllViews(NULL);
  346. #else
  347. CRect MapRect;
  348. CDC *pDC = GetDC();
  349. double gx,gy;
  350. gx = CovertStdNE(strGX);
  351. gy = CovertStdNE(strGY);
  352. if(!m_cDrawMap.CheckMapIsChange(gx,gy)) {
  353. if(!IsSimulate) {
  354. if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) return;
  355. }
  356. m_cDrawMap.DrawGpsCar(pDC,0.0);
  357. m_cDrawMap.GetCarXY(m_nx,m_ny);
  358. m_bDrawMap = TRUE;
  359. return;
  360. }
  361. if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) return;
  362. if(IsSimulate) return;
  363. GetClientRect(MapRect);
  364. m_cDrawMap.RefreshMapWnd();
  365. if(!m_cDrawMap.SaveRecePoint(gx,gy,pDC,strVehicleNO)) return;
  366. m_cDrawMap.DrawGpsCar(pDC,0.0);
  367. //获取车位置
  368. m_cDrawMap.GetCarXY(m_nx,m_ny);
  369. m_bDrawMap = TRUE;
  370. #endif
  371. }
  372. void CGpsSCView::InvalidRect(double gx, double gy)
  373. {
  374. long x,y;
  375. if(!m_cDrawMap.CalcNE2XY(gx,gy,x,y)) return;
  376. CRect lpRect;
  377. CPoint point = GetScrollPosition();
  378. long MidWidth = 100;
  379. x -= point.x;
  380. y -= point.y;
  381. lpRect.left = x - MidWidth - 20;
  382. lpRect.right = x + MidWidth + 20;
  383. lpRect.top = y - MidWidth;
  384. lpRect.bottom = y + MidWidth;
  385. CString str;
  386. str.Format("%d,%d,%d,%d",lpRect.left,lpRect.right,lpRect.top,lpRect.bottom);
  387. // StatusPrompt(str,0);
  388. // GetClientRect(lpRect);
  389. InvalidateRect(lpRect);
  390. }
  391. double CGpsSCView::CovertStdNE(CString StrNE)
  392. {
  393. CString Str,tmp;
  394. double dTmp;
  395. BYTE Len,i,chr;
  396. StrNE.Replace("r","");
  397. StrNE.Replace("n","");
  398. for(i = 0; i < StrNE.GetLength(); i ++) {
  399. chr = StrNE.GetAt(i);
  400. if(((chr < '0') || (chr > '9')) && (chr != '.')) {
  401. tmp = chr;
  402. StrNE.Replace(tmp,"");
  403. }
  404. }
  405. Len = StrNE.GetLength();
  406. Str = StrNE.Right(2);
  407. StrNE = StrNE.Left(Len - 2);
  408. StrNE.Replace(".","");
  409. dTmp = atof(Str);
  410. dTmp = dTmp / 60.0;
  411. return atof(StrNE) + dTmp;
  412. }
  413. void CGpsSCView::OnMouseMove(UINT nFlags, CPoint point)
  414. {
  415. // TODO: Add your message handler code here and/or call default
  416. if(m_bLButtomDown) {
  417. SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_MOVE));
  418. }
  419. TrackDispData(point);
  420. CheckMousePointInList(point);
  421. MoveFatMap(point);
  422. CScrollView::OnMouseMove(nFlags, point);
  423. }
  424. void CGpsSCView::MoveFatMap(CPoint point)
  425. {
  426. int nScale=4;
  427. if(!m_bMoveFatMap) return;
  428. int nHMove, nVMove, i;
  429. nHMove = (point.y - m_pRBDownPoint.y) / nScale;
  430. nVMove = (point.x - m_pRBDownPoint.x) / nScale;
  431. m_nVMove+=point.x - m_pRBDownPoint.x;
  432. m_nHMove+=point.y - m_pRBDownPoint.y;
  433. if(nHMove > 0) {
  434. for(i = 0; i < nHMove; i++) {
  435. OnVScroll(SB_LINEUP, 0 ,NULL); //响应UP键
  436. }
  437. m_nHMove=0;
  438. }
  439. else{
  440. if(m_nHMove>=nScale){
  441. // OnVScroll(SB_LINEUP, 0 ,NULL); //响应UP键
  442. m_nHMove=0;
  443. }
  444. }
  445. if(nHMove < 0) {
  446. nHMove = -nHMove;
  447. for(i = 0; i < nHMove; i++) {
  448. OnVScroll(SB_LINEDOWN, 0 ,NULL); //响应DOWN键
  449. }
  450. m_nHMove=0;
  451. }
  452. else{
  453. if(m_nHMove<=-nScale){
  454. // OnVScroll(SB_LINEDOWN, 0 ,NULL); //响应DOWN键
  455. m_nHMove=0;
  456. }
  457. }
  458. if(nVMove > 0) {
  459. for(i = 0; i < nVMove; i++) {
  460. OnHScroll(SB_LINELEFT, 0 ,NULL); //响应LEFT键
  461. }
  462. m_nVMove=0;
  463. }
  464. else{
  465. if(m_nVMove>=nScale){
  466. // OnHScroll(SB_LINELEFT, 0 ,NULL); //响应LEFT键
  467. m_nVMove=0;
  468. }
  469. }
  470. if(nVMove < 0) {
  471. nVMove=-nVMove;
  472. for(i = 0; i < nVMove; i++) {
  473. OnHScroll(SB_LINERIGHT, 0 ,NULL); //响应RIGHT键
  474. }
  475. m_nVMove=0;
  476. }
  477. else{
  478. if(m_nVMove<=-nScale){
  479. // OnHScroll(SB_LINERIGHT, 0 ,NULL); //响应RIGHT键
  480. m_nVMove=0;
  481. }
  482. }
  483. m_pRBDownPoint = point;
  484. }
  485. /*************Set status prompt*************/
  486. void CGpsSCView::StatusPrompt(CString pmt,UINT uID)
  487. {
  488. CStatusBar* pStatus=(CStatusBar*)
  489. AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_VIEW_STATUS_BAR);
  490. ASSERT(pStatus);
  491. if(pStatus) {
  492. pStatus->SetPaneText(uID,pmt,TRUE);
  493. }
  494. }
  495. void CGpsSCView::CovertDFS(double LongNE,int *Angle,int *Minute,int *Second)
  496. {
  497. double dTmp;
  498. dTmp = LongNE;
  499. dTmp = dTmp / 100.0;
  500. *Angle = (int)(dTmp);
  501. dTmp = (dTmp - *Angle) * 100.0;
  502. *Minute = (int)(dTmp);
  503. *Second = (int)((dTmp - *Minute) * 60);
  504. }
  505. void CGpsSCView::TrackDispData(CPoint point)
  506. {
  507. CGpsPoint cGpsPoint;
  508. CString Prompt;
  509. int Angle1,Minute1,Second1,Angle2,Minute2,Second2;
  510. cGpsPoint.m_lx = point.x; cGpsPoint.m_ly = point.y;
  511. m_cDrawMap.CovertNEXY(&cGpsPoint, m_cDrawMap.m_cCurrMapInfo.CoeffXY_NE, false);
  512. CovertDFS(cGpsPoint.m_dgx,&Angle1,&Minute1,&Second1);
  513. CovertDFS(cGpsPoint.m_dgy,&Angle2,&Minute2,&Second2);
  514. Prompt.Format("(%d,%d);(%d°%02d′%02d″,%d°%02d′%02d″)",point.x,point.y,Angle1,Minute1,Second1,Angle2,Minute2,Second2);
  515. StatusPrompt(Prompt,1);
  516. }
  517. void CGpsSCView::OnTimer(UINT nIDEvent) 
  518. {
  519. // TODO: Add your message handler code here and/or call default
  520. #if 0
  521. CGpsSCDoc* pDoc = GetDocument();
  522. ASSERT_VALID(pDoc);
  523. CString SystemTitle;
  524. SystemTitle = m_cDrawMap.m_cCurrMapInfo.m_LinkFileName;
  525. pDoc->SetTitle(SystemTitle);
  526. #endif
  527. CScrollView::OnTimer(nIDEvent);
  528. }
  529. void CGpsSCView::OnMzoomDown() 
  530. {
  531. // TODO: Add your command handler code here
  532. m_cDrawMap.ZoomDown();
  533. }
  534. void CGpsSCView::OnUpdateMzoomDown(CCmdUI* pCmdUI) 
  535. {
  536. // TODO: Add your command update UI handler code here
  537. }
  538. void CGpsSCView::OnMzoomUp()
  539. {
  540. // TODO: Add your command handler code here
  541. m_cDrawMap.ZoomUp();
  542. }
  543. void CGpsSCView::OnUpdateMzoomUp(CCmdUI* pCmdUI)
  544. {
  545. // TODO: Add your command update UI handler code here
  546. }
  547. //开锁
  548. void CGpsSCView::OnOpenlock()
  549. {
  550. // TODO: Add your command handler code here
  551. procSM.OnOpenlock();
  552. }
  553. //取位置
  554. void CGpsSCView::OnGetvehicleposition() 
  555. {
  556. // TODO: Add your command handler code here
  557. procSM.OnGetvehicleposition();
  558. }
  559. //上锁
  560. void CGpsSCView::OnSetlock() 
  561. {
  562. // TODO: Add your command handler code here
  563. procSM.OnSetlock();
  564. }
  565. //断油
  566. void CGpsSCView::OnShutoil() 
  567. {
  568. // TODO: Add your command handler code here
  569. procSM. OnShutoil();
  570. }
  571. void  CGpsSCView::SetCommonUserTelNo(CString)
  572. {
  573. }
  574. //Host change his owen password
  575. void CGpsSCView::OnSetpassword() 
  576. {
  577. procSM.HoseChangePassWord();
  578. }
  579. void CGpsSCView::OnSendnormalsm() 
  580. {
  581. // TODO: Add your command handler code here
  582. AfxMessageBox("对不起! 此功能只提供给正式版用户!");
  583. }
  584. void CGpsSCView::OnSendinfotogroup() 
  585. {
  586. // TODO: Add your command handler code here
  587. AfxMessageBox("对不起! 此功能只提供给正式用户!");
  588. }
  589. void CGpsSCView::OnSelectUserType() 
  590. {
  591. // TODO: Add your command handler code here
  592. procSM.SelectUserType();
  593. if(procSM.m_nUserType==1)
  594. flag_usertype=FALSE;
  595. if(procSM.m_nUserType==0)
  596. flag_usertype=TRUE;
  597. }
  598. void CGpsSCView::OnAutomonitor() 
  599. {
  600. // TODO: Add your command handler code here
  601. procSM.AutoMonitor();
  602. }
  603. void CGpsSCView::OnGethelp() 
  604. {
  605. // TODO: Add your command handler code here
  606. procSM.GetHelp();
  607. }
  608. void CGpsSCView::OnShowconnetDlg()
  609. {
  610. // CGpsSCApp *vpsapp=NULL;
  611. /* {
  612.      m_pDoc = GetDocument();
  613.      if(m_pDoc->OnConnetComm())
  614. procSM.SystermInite(this);
  615. }*/
  616. }
  617. void CGpsSCView::OnMdispSignPoint() 
  618. {
  619. // TODO: Add your command handler code here
  620. if(!m_bDispSignPoint) {
  621. if(!m_cDrawMap.ShowSignLib()) return;
  622. m_bDispSignPoint = true;
  623. }
  624. else {
  625. m_bDispSignPoint = false;
  626. }
  627. OnRefresh();
  628. }
  629. void CGpsSCView::OnUpdateMdispSignPoint(CCmdUI* pCmdUI) 
  630. {
  631. // TODO: Add your command update UI handler code here
  632. }
  633. void CGpsSCView::OnMsearchSignByRegion() 
  634. {
  635. // TODO: Add your command handler code here
  636. m_bSearchSignbyRegion = true;
  637. m_cDrawMap.SearchSign();
  638. }
  639. void CGpsSCView::OnUpdateMsearchSignByRegion(CCmdUI* pCmdUI) 
  640. {
  641. // TODO: Add your command update UI handler code here
  642. pCmdUI->Enable(theApp.m_bUserType);
  643. }
  644. void CGpsSCView::OnMsearchBestRoad() 
  645. {
  646. // TODO: Add your command handler code here
  647. if(!m_bSearchBestRoad) {
  648. m_bSearchBestRoad = true;
  649. AfxMessageBox("请选择起点");
  650. }
  651. else {
  652. m_bSearchBestRoad = false;
  653. OnRefresh();
  654. }
  655. }
  656. void CGpsSCView::OnUpdateMsearchBestRoad(CCmdUI* pCmdUI) 
  657. {
  658. // TODO: Add your command update UI handler code here
  659. pCmdUI->Enable(FALSE);
  660. }
  661. void CGpsSCView::OnFindmessage() 
  662. {
  663. // TODO: Add your command handler code here
  664. CFindMessageDlg dlg;
  665. dlg.DoModal();
  666. }
  667. void CGpsSCView::OnUpdateAutomonitor(CCmdUI* pCmdUI) 
  668. {
  669. // TODO: Add your command update UI handler code here
  670. BOOL MenuEnable = procSM.m_bSysTemInit;
  671. // MenuEnable = MenuEnable && flag_usertype;
  672. pCmdUI->Enable(MenuEnable);
  673. }
  674. void CGpsSCView::OnLButtonDown(UINT nFlags, CPoint point) 
  675. {
  676. // TODO: Add your message handler code here and/or call default
  677. DrawMoveRect(point);
  678. if(m_bSearchBestRoad) m_cDrawMap.CalculateBRroadPath(point);
  679. m_bMoveFatMap = true;
  680. m_pRBDownPoint = point;
  681. CScrollView::OnLButtonDown(nFlags, point);
  682. }
  683. void CGpsSCView::DrawMoveRect(CPoint point)
  684. {
  685. if(!m_bLButtomDown) {
  686. SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_MOVE));
  687. m_bLButtomDown = true;
  688. }
  689. return;
  690. CRectTracker cRect;
  691. CPoint cPoint;
  692. cRect.m_rect.SetRect(10, 10, 300, 300);
  693. cRect.m_nStyle = CRectTracker::resizeInside | CRectTracker::dottedLine; 
  694. cRect.TrackRubberBand(this,point);
  695. }
  696. void CGpsSCView::OnLButtonUp(UINT nFlags, CPoint point) 
  697. {
  698. // TODO: Add your message handler code here and/or call default
  699. if(m_bLButtomDown) {
  700. m_bLButtomDown = false;
  701. }
  702. m_bMoveFatMap = false;
  703. CScrollView::OnLButtonUp(nFlags, point);
  704. }
  705. void CGpsSCView::OnUpdateGetvehicleposition(CCmdUI* pCmdUI) 
  706. {
  707. // TODO: Add your command update UI handler code here
  708. pCmdUI->Enable(procSM.m_bSysTemInit);
  709. }
  710. void CGpsSCView::OnUpdateSetlock(CCmdUI* pCmdUI) 
  711. {
  712. // TODO: Add your command update UI handler code here
  713. pCmdUI->Enable(procSM.m_bSysTemInit);
  714. }
  715. void CGpsSCView::OnUpdateShutoil(CCmdUI* pCmdUI) 
  716. {
  717. // TODO: Add your command update UI handler code here
  718. pCmdUI->Enable(procSM.m_bSysTemInit);
  719. }
  720. void CGpsSCView::OnUpdateGethelp(CCmdUI* pCmdUI) 
  721. {
  722. // TODO: Add your command update UI handler code here
  723. pCmdUI->Enable(procSM.m_bSysTemInit);
  724. }
  725. void CGpsSCView::OnUpdateOpenlock(CCmdUI* pCmdUI) 
  726. {
  727. // TODO: Add your command update UI handler code here
  728. pCmdUI->Enable(procSM.m_bSysTemInit);
  729. }
  730. void CGpsSCView::OnUpdateSendnormalsm(CCmdUI* pCmdUI) 
  731. {
  732. // TODO: Add your command update UI handler code here
  733. pCmdUI->Enable(procSM.m_bSysTemInit);
  734. }
  735. void CGpsSCView::OnUpdateSendinfotogroup(CCmdUI* pCmdUI) 
  736. {
  737. // TODO: Add your command update UI handler code here
  738. pCmdUI->Enable(procSM.m_bSysTemInit);
  739. }
  740. void CGpsSCView::OnUpdateSelecttype(CCmdUI* pCmdUI) 
  741. {
  742. // TODO: Add your command update UI handler code here
  743. pCmdUI->Enable(procSM.m_bSysTemInit);
  744. }
  745. void CGpsSCView::OnUpdateChangeuserpassword(CCmdUI* pCmdUI) 
  746. {
  747. // TODO: Add your command update UI handler code here
  748. pCmdUI->Enable(procSM.m_bSysTemInit);
  749. }
  750. void CGpsSCView::OnUpdateSetpassword(CCmdUI* pCmdUI) 
  751. {
  752. // TODO: Add your command update UI handler code here
  753. pCmdUI->Enable(procSM.m_bSysTemInit);
  754. }
  755. void CGpsSCView::OnCconnectCom() 
  756. {
  757. // TODO: Add your command handler code here
  758. CGpsSCDoc *pDoc = GetDocument();
  759. ASSERT_VALID(pDoc);
  760. m_pDoc->OnConnetComm();
  761. procSM.m_bSysTemInit = FALSE;
  762. }
  763. void CGpsSCView::OnUpdateCconnectCom(CCmdUI* pCmdUI) 
  764. {
  765. // TODO: Add your command update UI handler code here
  766. pCmdUI->Enable(!procSM.m_bSysTemInit);
  767. }
  768. void CGpsSCView::OnCdisconnetComm() 
  769. {
  770. // TODO: Add your command handler code here
  771. CGpsSCDoc *pDoc = GetDocument();
  772. ASSERT_VALID(pDoc);
  773. pDoc->CloseConnection();
  774. procSM.m_bSysTemInit = FALSE;
  775. }
  776. void CGpsSCView::OnUpdateCdisconnetComm(CCmdUI* pCmdUI) 
  777. {
  778. // TODO: Add your command update UI handler code here
  779. pCmdUI->Enable(procSM.m_bSysTemInit);
  780. }
  781. LRESULT CGpsSCView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
  782. {
  783. // TODO: Add your specialized code here and/or call the base class
  784. switch(message)
  785. {   
  786. case WM_MOUSEMOVE:
  787. {
  788. MSG msg;
  789. msg.hwnd=m_hWnd;
  790. msg.message=message;
  791. msg.wParam=wParam;
  792. msg.lParam=lParam;
  793. m_ToolTip.RelayEvent(&msg);
  794. }
  795. }
  796. return CScrollView::WindowProc(message, wParam, lParam);
  797. }
  798. BOOL CGpsSCView::PreTranslateMessage(MSG* pMsg) 
  799. {
  800. // TODO: Add your specialized code here and/or call the base class
  801. if(m_ToolTip) 
  802. m_ToolTip.RelayEvent(pMsg); 
  803. m_ToolTip.SetTipBkColor(RGB(050,250,255));
  804. return CScrollView::PreTranslateMessage(pMsg);
  805. }
  806. void CGpsSCView::OnCancelautomonitor() 
  807. {
  808. // TODO: Add your command handler code here
  809. procSM.CanceLautoMonitor();
  810. if(procSM.CheckMonitorCar())
  811. {
  812. CMainFrame*  mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
  813. bool bConctrol = false;
  814. mainfrm->EditTreeItem(bConctrol);
  815. }
  816. }
  817. void CGpsSCView::OnUpdateCancelautomonitor(CCmdUI* pCmdUI) 
  818. {
  819. // TODO: Add your command update UI handler code here
  820. pCmdUI->Enable(procSM.m_bSysTemInit);
  821. }
  822. void CGpsSCView::CheckMousePointInList(CPoint point)
  823. {
  824. CMainFrame *pMainFrame = NULL;
  825. CString Str,Data("");
  826. int nListCount,i;
  827. // int j;
  828. double gx,gy;
  829. long x,y;
  830. pMainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
  831. nListCount = pMainFrame->m_wndListCtrl.GetItemCount();
  832. for(i = 0; i < nListCount; i++) {
  833. gx = CovertStdNE(pMainFrame->m_wndListCtrl.GetItemText(i,5));
  834. gy = CovertStdNE(pMainFrame->m_wndListCtrl.GetItemText(i,6));
  835. // for(j = 0; j < 7; j++) {
  836. Data="";
  837. Str.Format("%s,%c",pMainFrame->m_wndListCtrl.GetItemText(i,1),'n');
  838. Data += Str;
  839. Str.Format("%s,%c",pMainFrame->m_wndListCtrl.GetItemText(i,2),'n');
  840. Data += Str;
  841. Str.Format("%s,%c",pMainFrame->m_wndListCtrl.GetItemText(i,7),'n');
  842. Data += Str;
  843. Str.Format("%s",pMainFrame->m_wndListCtrl.GetItemText(i,9));
  844. Data += Str;
  845. // }
  846. m_cDrawMap.CalcNE2XY(gx,gy,x,y);
  847. if((abs(point.x - x) < 3) && (abs(point.y - y) < 3)) {
  848. m_ToolTip.AddTool(this,Data);
  849. m_ToolTip.Activate(TRUE);
  850. }
  851. }
  852. }
  853. //移动滚动条
  854. void CGpsSCView::MoveScroll()
  855. {
  856. int nx,ny;
  857. nx=ny=0;
  858. if((m_bDrawMap==TRUE)&&(m_cDrawMap.m_byZoomCoeffic>1))
  859. {
  860. SetScrollRange(SB_HORZ,0,430,TRUE);
  861. SetScrollRange(SB_VERT,0,260,TRUE);
  862. if(m_nx>430)
  863. nx = m_nx-430;
  864. if(m_ny>260)
  865. ny = m_ny-260;
  866. SetScrollPos(SB_HORZ,nx,TRUE);
  867. SetScrollPos(SB_VERT,ny,TRUE);
  868. }
  869. m_bDrawMap = FALSE;
  870. }
  871. void CGpsSCView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
  872. {
  873. // TODO: Add your message handler code here and/or call default
  874. m_bDrawMap = FALSE;
  875. CScrollView::OnVScroll(nSBCode, nPos, pScrollBar);
  876. }
  877. void CGpsSCView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
  878. {
  879. // TODO: Add your message handler code here and/or call default
  880. m_bDrawMap = FALSE;
  881. CScrollView::OnHScroll(nSBCode, nPos, pScrollBar);
  882. }
  883. void CGpsSCView::OnPopFresh() 
  884. {
  885. // TODO: Add your command handler code here
  886. CGpsSCDoc* pDoc = GetDocument();
  887. ASSERT_VALID(pDoc);
  888. pDoc->UpdateAllViews(NULL);
  889. }
  890. void CGpsSCView::OnUpdatePopFresh(CCmdUI* pCmdUI) 
  891. {
  892. // TODO: Add your command update UI handler code here
  893. }
  894. void CGpsSCView::OnRButtonDown(UINT nFlags, CPoint point) 
  895. {
  896. // TODO: Add your message handler code here and/or call default
  897. CMenu PopMenu,*pSubMenu;
  898. CRect lpRect;
  899. GetWindowRect(&lpRect);
  900. PopMenu.LoadMenu(IDR_POP_MENU);
  901. pSubMenu = PopMenu.GetSubMenu(1);
  902. pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
  903. point.x + lpRect.left,
  904. point.y + lpRect.top, AfxGetMainWnd(),NULL);
  905. pSubMenu = NULL;
  906. PopMenu.DestroyMenu();
  907. CScrollView::OnRButtonDown(nFlags, point);
  908. }
  909. void CGpsSCView::OnMsearchSign() 
  910. {
  911. // TODO: Add your command handler code here
  912. m_bSearchSignbyRegion = true;
  913. m_cDrawMap.SearchSignByInput();
  914. }
  915. void CGpsSCView::OnUpdateMsearchSign(CCmdUI* pCmdUI) 
  916. {
  917. // TODO: Add your command update UI handler code here
  918. }
  919. BOOL CGpsSCView::OnEraseBkgnd(CDC* pDC) 
  920. {
  921. // TODO: Add your message handler code here and/or call default
  922. return FALSE;
  923. // return CScrollView::OnEraseBkgnd(pDC);
  924. }
  925. void CGpsSCView::OnCancelCurrMonitorCar() 
  926. {
  927. // TODO: Add your command handler code here
  928. if(procSM.CheckMonitorCar())
  929. {
  930. CMainFrame*  mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
  931. bool bConctrol = false;
  932. mainfrm->EditTreeItem(bConctrol);
  933. }
  934. }
  935. void CGpsSCView::OnUpdateCancelCurrMonitorCar(CCmdUI* pCmdUI) 
  936. {
  937. // TODO: Add your command update UI handler code here
  938. BOOL MenuEnable = procSM.m_bSysTemInit;
  939. pCmdUI->Enable(MenuEnable);
  940. }
  941. void CGpsSCView::OnSetCurrMonitorCar()
  942. {
  943. // TODO: Add your command handler code here
  944. CClientinfoSet cSet;
  945. CString VehicleID,VehicleTel;
  946. CMainFrame*  mainfrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
  947. cSet.FindCarNumberAndPhone(str_GetTreeItemText,VehicleID,VehicleTel);
  948. procSM.SetMonitorCar(VehicleID);
  949. if(!procSM.CheckMonitorCar())
  950. {
  951. mainfrm->EditTreeItem();
  952. }
  953. }
  954. void CGpsSCView::OnUpdateSetCurrMonitorCar(CCmdUI* pCmdUI)
  955. {
  956. // TODO: Add your command update UI handler code here
  957. BOOL MenuEnable = procSM.m_bSysTemInit;
  958. pCmdUI->Enable(MenuEnable);
  959. }
  960. void CGpsSCView::OnUpdateCconnetComm(CCmdUI* pCmdUI) 
  961. {
  962. // TODO: Add your command update UI handler code here
  963. pCmdUI->Enable(theApp.m_bUserType);
  964. }