[HowTo:]如何在VC++中使用MAPX控件,并实现鹰眼联动功能
摘要
MapX 控件是一个常用的GIS功能组件,而鹰眼图是GIS中一个基本的功能。本文主要说明在VC++ .NET下如何利用MapX 控件实现鹰眼
图,并使它与主图联动。
问题
关于在VC++(以下操作均在VC++ .NET下实现,VC6中只是操作步骤稍有不同,原理一致)中增加MAPX控件这一问题,MAPX的.hlp文件
里面已经有详细的描述,鹰眼图的使用也在网址[1]中有涉及。但是存在如下不足:
A).hlp是英文的,而且步骤描述针对VC6
B)[1]中的主要描述语言是VB,与之对应的VC部分的描述有所错漏,并且鹰眼图没有涉及"联动"这一最常用的功能
本文主要解决上述问题。
说明
本文实验环境为 .NET 1.1,MAPX4.5。
为了让鹰眼图脱离主View单独浮动,决定使用CJLibrary控件来放置鹰眼图,该控件可由网址[2]下载。
鹰眼图上面有一个红色矩形框,表示主图的当前可视范围。要求点击鼠标左键来移动此框时能够引起主图的联动。
主图上有放大、缩小、移动三个工具按钮,要求主图变化的时候,能够引起鹰眼图矩形框的联动。
实现的易错点在CMapXEagleBar::OnMouseUpInMap函数, 鹰眼图中矩形框的移动要经过如下几步:
a) 得到矩形框四个顶点移动前的屏幕坐标,
b) 计算出中心点坐标,
c) 通过消息传入的参数得到移动后的中心点屏幕坐标
d) 计算前后中心点的偏移(以屏幕坐标作为参考)
e) 计算移动后的矩形框的四个顶点的屏幕坐标
f) 将四个顶点的屏幕坐标转换成地理坐标
g) 显示新的矩形框
源码下载: https://files.cnblogs.com/eXcel/MapXSampleMDI.rar
详细步骤
1) 新建MDI项目MapXSampleMDI,视图类为CMapXSampleMDIView
2)打开MAPX安装目录,找到 MapX 4.0\Samples40\C++\Buffer 子目录下的MAPX.H, MAPX.CPP两个文件,将这两个文件复制到
MapXSampleMDI的项目目录中
3)在stdafx.h中增加 #include "MapX.h"
4)通过菜单中的"文件"->"添加现有项",将MAPX.CPP加入项目中
5)在资源中增加两个字符串IDC_MAP,IDC_MAP_EAGLE,字符串的值无所谓,采用系统缺省值就行
6) 资源中新建一个名为IDR_TOOLBARMAP的TOOLBAR
ID分别为 ID_MAP_TOOL_ZOOMIN, ID_MAP_TOOL_ZOOMOUT, ID_MAP_TOOL_PAN
7)在MapXSampleMDIView.h增加如下成员
2 CMapX m_ctrlMapX;
3
4//消息映射函数
5protected:
6 DECLARE_MESSAGE_MAP()
7 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
8 afx_msg void OnSize(UINT nType, int cx, int cy);
9 afx_msg void OnSetFocus(CWnd* pOldWnd);
10 afx_msg void OnMapToolPan();
11 afx_msg void OnMapToolZoomin();
12 afx_msg void OnMapToolZoomout();
13 afx_msg void OnUpdateMapToolPan(CCmdUI* pCmdUI);
14 afx_msg void OnUpdateMapToolZoomin(CCmdUI* pCmdUI);
15 afx_msg void OnUpdateMapToolZoomout(CCmdUI* pCmdUI);
16 DECLARE_EVENTSINK_MAP()
17 afx_msg void OnMapViewChanged();
18 virtual void OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/);
19
8)在MapXSampleMDIView.CPP中增加如下代码
2
3BEGIN_MESSAGE_MAP(CMapXSampleMDIView, CView)
4 ON_WM_CREATE()
5 ON_WM_SIZE()
6 ON_WM_SETFOCUS()
7 ON_COMMAND(ID_MAP_TOOL_PAN, OnMapToolPan)
8 ON_COMMAND(ID_MAP_TOOL_ZOOMIN, OnMapToolZoomin)
9 ON_COMMAND(ID_MAP_TOOL_ZOOMOUT, OnMapToolZoomout)
10 ON_UPDATE_COMMAND_UI(ID_MAP_TOOL_PAN, OnUpdateMapToolPan)
11 ON_UPDATE_COMMAND_UI(ID_MAP_TOOL_ZOOMIN, OnUpdateMapToolZoomin)
12 ON_UPDATE_COMMAND_UI(ID_MAP_TOOL_ZOOMOUT, OnUpdateMapToolZoomout)
13END_MESSAGE_MAP()
14
15BEGIN_EVENTSINK_MAP(CMapXSampleMDIView, CView)
16 ON_EVENT(CMapXSampleMDIView, IDC_MAP, MAPX_DISPID_MAPVIEWCHANGED, OnMapViewChanged, VTS_NONE)
17END_EVENTSINK_MAP()
18
19// CMapXSampleMDIView 消息处理程序
20int CMapXSampleMDIView::OnCreate(LPCREATESTRUCT lpCreateStruct)
21{
22 if (CView::OnCreate(lpCreateStruct) == -1)
23 return -1;
24 // TODO: 在此添加您专用的创建代码
25 //创建主图控件
26 if (!m_ctrlMapX.Create(NULL, WS_VISIBLE, CRect(0,0,100,100), this,IDC_MAP))
27 return -1;
28 //创建缺省工具栏
29 m_ctrlMapX.CreateCustomTool(CUST_INFO, miToolTypePoint, miCrossCursor);
30 return 0;
31}
32
33void CMapXSampleMDIView::OnSize(UINT nType, int cx, int cy)
34{
35 CView::OnSize(nType, cx, cy);
36 // TODO: 在此处添加消息处理程序代码
37 if (cx != 0 && cy != 0)
38 m_ctrlMapX.MoveWindow(0,0,cx,cy,TRUE);
39}
40
41void CMapXSampleMDIView::OnSetFocus(CWnd* pOldWnd)
42{
43 CView::OnSetFocus(pOldWnd);
44 // TODO: 在此处添加消息处理程序代码
45 m_ctrlMapX.SetFocus();
46}
47
48
49void CMapXSampleMDIView::OnMapToolPan()
50{
51 m_ctrlMapX.SetCurrentTool(miPanTool);
52}
53void CMapXSampleMDIView::OnMapToolZoomin()
54{
55 m_ctrlMapX.SetCurrentTool(miZoomInTool);
56}
57void CMapXSampleMDIView::OnMapToolZoomout()
58{
59 m_ctrlMapX.SetCurrentTool(miZoomOutTool);
60}
61void CMapXSampleMDIView::OnUpdateMapToolPan(CCmdUI* pCmdUI)
62{
63 pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miPanTool);
64}
65void CMapXSampleMDIView::OnUpdateMapToolZoomin(CCmdUI* pCmdUI)
66{
67 pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miZoomInTool);
68}
69void CMapXSampleMDIView::OnUpdateMapToolZoomout(CCmdUI* pCmdUI)
70{
71 pCmdUI->SetCheck(m_ctrlMapX.GetCurrentTool() == miZoomOutTool);
72}
73
74//主地图的放大、缩小、移动会引发事件调用此函数
75void CMapXSampleMDIView::OnMapViewChanged()
76{
77 CMapXRectangle rect; //声明矩形变量
78 rect.CreateDispatch(rect.GetClsid());
79 //获取主图的边界,根据这个边界值,在鹰眼图上添加一个矩形Feature
80 rect = m_ctrlMapX.GetBounds();
81 DoubleRect doubleRect;
82 //获取主图的边界,根据这个边界值,在鹰眼图上添加一个矩形Feature
83 doubleRect.X1 = rect.GetXMin(); //获得矩形左上顶点x坐标
84 doubleRect.Y1 = rect.GetYMin(); //获得矩形左上顶点y坐标
85 doubleRect.X2 = rect.GetXMax(); //获得矩形右下顶点x坐标
86 doubleRect.Y2 = rect.GetYMax(); //获得矩形右下顶点y坐标
87
88 //发送消息通知CMapXEagleBar,该消息由MainFrm接收并传递
89 AfxGetMainWnd()->SendMessage(WM_MAPXVIEW_CHANGED, 0, (LPARAM)&doubleRect);
90}
91//鹰眼图上面点击鼠标左键时引发矩形框移动,通过消息传递,最终调用此函数
92void CMapXSampleMDIView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
93{
94 // TODO: 在此添加专用代码和/或调用基类
95 CMapXSampleMDIDoc* pDoc=GetDocument();
96 double x=pDoc->CenterPointX;
97 double y=pDoc->CenterPointY;
98
99 if(int(x)!=0 && int(y)!=0)
100 {
101 double zoom=m_ctrlMapX.GetZoom();
102 m_ctrlMapX.ZoomTo(zoom,x,y);
103 }
104}
105
106
9)stdafx.h中增加#include "CJLibrary.h"
把CJLibrary的头文件路径加进 MapXSampleMDI 项目属性中的 "C/C++" -> "附加包含目录"中
把CJLibrary的静态库文件路径加进 MapXSampleMDI 项目属性中的 "链接器" -> "附加包含目录"中
把CJLibrary的动态库文件复制到 MapXSampleMDI 项目的输出目录中
10)新建类CMapXEagleBar,代码如下
//MapXEagleBar.h
2{
3 DECLARE_DYNAMIC(CMapXEagleBar)
4
5public:
6 CMapXEagleBar();
7 virtual ~CMapXEagleBar();
8
9protected:
10 DECLARE_MESSAGE_MAP()
11 DECLARE_EVENTSINK_MAP()
12
13protected:
14 CMapX m_eagleMapx; //鹰眼图
15 CMapXFeature m_eaglefeature; //矩形框
16
17public:
18 //{{AFX_MSG(CMapXEagleBar)
19 afx_msg void OnSize(UINT nType, int cx, int cy);
20 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
21 afx_msg bool OnMouseUpInMap(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y); //鼠标左键点击的事件处理
22 //}}AFX_MSG
23
24 void OnMapViewChange(double X1,double Y1,double X2,double Y2); //主图变化引发的事件, 经过消息传递之后, 调用此函数
25};
26
//MapXEagleBar.cpp
2 //{{AFX_MSG_MAP(CWarnListBar)
3 ON_WM_SIZE()
4 ON_WM_CREATE()
5 //}}AFX_MSG_MAP
6END_MESSAGE_MAP()
7
8BEGIN_EVENTSINK_MAP(CMapXEagleBar, CCJControlBar)
9 ON_EVENT(CMapXEagleBar, IDC_MAP_EAGLE, DISPID_MOUSEUP,OnMouseUpInMap, VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS)
10END_EVENTSINK_MAP()
11
12// CMapXEagleBar 消息处理程序
13int CMapXEagleBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
14{
15 if (CCJControlBar::OnCreate(lpCreateStruct) == -1)
16 return -1;
17
18 //创建鹰眼图控件
19 if (!m_eagleMapx.Create(NULL, WS_VISIBLE, CRect(0,0,250,250), this,IDC_MAP_EAGLE))
20 return -1;
21 //创建一个图层,用于显示鹰眼图上矩形Feature
22 m_eagleMapx.GetLayers().CreateLayer("RectLayer");
23
24 return 0;
25}
26
27void CMapXEagleBar::OnSize(UINT nType, int cx, int cy)
28{
29 CCJControlBar::OnSize(nType, cx, cy);
30 if (cx != 0 && cy != 0)
31 m_eagleMapx.MoveWindow(0,0,cx,cy,TRUE);
32
33}
34void CMapXEagleBar::OnMapViewChange(double X1,double Y1,double X2,double Y2)
35{
36 double x2,y2,x4,y4; //声明坐标变量
37 VARIANT scx, scy, scx1, scy1; //声明屏幕坐标变量
38 VARIANT mapx1,mapy1,mapx2,mapy2; //声明地图坐标变量
39 //声明FeatureFactory变量并获取缺省值
40 CMapXFeatureFactory cFactory=m_eagleMapx.GetFeatureFactory();
41 CMapXLayer layer; //声明图层变量
42 CMapXFeature feature; //声明Feature变量
43 CMapXFeatures features; //声明Features变量
44 CMapXPoints points; //声明Points变量
45 points.CreateDispatch(points.GetClsid());
46
47 //进行坐标变换
48 m_eagleMapx.ConvertCoordV(&scx,&scy,COleVariant(X1),COleVariant(Y1),miMapToScreen);
49 m_eagleMapx.ConvertCoordV(&scx1,&scy1,COleVariant(X2),COleVariant(Y2),miMapToScreen);
50 m_eagleMapx.ConvertCoordV(&scx,&scy1,&mapx1,&mapy1,miScreenToMap);
51 m_eagleMapx.ConvertCoordV(&scx1,&scy,&mapx2,&mapy2,miScreenToMap);
52
53 //获得矩形框顶点坐标
54 x2=mapx1.dblVal;
55 y2=mapy1.dblVal;
56 x4=mapx2.dblVal;
57 y4=mapy2.dblVal;
58
59 //得到添加矩形Feature的图层
60 layer=m_eagleMapx.GetLayers().Item("RectLayer");
61 features=layer.AllFeatures();
62 //没有添加矩形Feature的图层,则新建
63 if(features.GetCount() == 0)
64 {
65 //添加四个顶点构成一个矩形框
66 points.AddXY(X1,Y1); //添加顶点1
67 points.AddXY(x2,y2); //添加顶点2
68 points.AddXY(X2,Y2); //添加顶点3
69 points.AddXY(x4,y4); //添加顶点4
70 //创建矩形Feature
71 COleVariant vtPoints;
72 vtPoints.vt = VT_DISPATCH;
73 vtPoints.pdispVal = points.m_lpDispatch;
74 vtPoints.pdispVal->AddRef();
75 feature=cFactory.CreateRegion(vtPoints);
76 //设置矩形Feature的属性
77 CMapXStyle style=feature.GetStyle();
78 style.SetRegionPattern(miPatternNoFill); //设置矩形的填充方式
79 style.SetRegionBorderColor(miColorRed); //设置矩形边框颜色
80 style.SetRegionBorderWidth(2); //设置矩形边框宽度
81 feature.SetStyle(style.m_lpDispatch);
82 //添加已经创建的矩形Feature
83 m_eaglefeature = layer.AddFeature(feature);
84 }
85 else //否则更新Feature的矩形大小与位置
86 {
87 m_eaglefeature.GetParts().Item(1).RemoveAll(); //除去已有的顶点
88 m_eaglefeature.GetParts().Item(1).AddXY(X1,Y1); //添加顶点1
89 m_eaglefeature.GetParts().Item(1).AddXY(x2,y2); //添加顶点2
90 m_eaglefeature.GetParts().Item(1).AddXY(X2,Y2); //添加顶点3
91 m_eaglefeature.GetParts().Item(1).AddXY(x4,y4); //添加顶点4
92 m_eaglefeature.Update(); //更新Feature属性
93 }
94 //更新显示图层
95 layer.Refresh();
96}
97
98bool CMapXEagleBar::OnMouseUpInMap(short ButtonFlag, short ShiftFlag, OLE_XPOS_PIXELS X, OLE_YPOS_PIXELS Y)
99{
100 if(ButtonFlag!=MK_LBUTTON)
101 return false;
102 // TODO: 在此添加消息处理程序代码和/或调用默认值
103
104 //得到原矩形框左上和右下两个顶点的坐标
105 double MapOld_x1=m_eaglefeature.GetParts().Item(1).Item(1).GetX();
106 double MapOld_x3=m_eaglefeature.GetParts().Item(1).Item(3).GetX();
107 double MapOld_y1=m_eaglefeature.GetParts().Item(1).Item(1).GetY();
108 double MapOld_y3=m_eaglefeature.GetParts().Item(1).Item(3).GetY();
109
110 //转换坐标体系为屏幕坐标
111 float ScreenOld_x1,ScreenOld_x3,ScreenOld_y1,ScreenOld_y3;
112 m_eagleMapx.ConvertCoord(&ScreenOld_x1, &ScreenOld_y1, &MapOld_x1, &MapOld_y1, miMapToScreen);
113 m_eagleMapx.ConvertCoord(&ScreenOld_x3, &ScreenOld_y3, &MapOld_x3, &MapOld_y3, miMapToScreen);
114
115 //计算原中心点(屏幕坐标)
116 float ScreenOldCenter_X=(ScreenOld_x1+ScreenOld_x3)/2;
117 float ScreenOldCenter_Y=(ScreenOld_y1+ScreenOld_y3)/2;
118
119 //新中心点(屏幕坐标)
120 float ScreenNewCenter_X=X;
121 float ScreenNewCenter_Y=Y;
122
123 //计算两点距离
124 float distance_x=ScreenNewCenter_X-ScreenOldCenter_X;
125 float distance_y=ScreenNewCenter_Y-ScreenOldCenter_Y;
126
127 //计算新矩形框左上和右下两个顶点的坐标
128 float ScreenNew_x1=ScreenOld_x1+distance_x;
129 float ScreenNew_x3=ScreenOld_x3+distance_x;
130 float ScreenNew_y1=ScreenOld_y1+distance_y;
131 float ScreenNew_y3=ScreenOld_y3+distance_y;
132
133 //转换坐标系为MAP坐标
134 double x1,x3,y1,y3;
135 m_eagleMapx.ConvertCoord(&ScreenNew_x1, &ScreenNew_y1, &x1, &y1, miScreenToMap);
136 m_eagleMapx.ConvertCoord(&ScreenNew_x3, &ScreenNew_y3, &x3, &y3, miScreenToMap);
137
138
139 //得到另外两个顶点的MAP坐标
140 VARIANT scx1, scy1, scx3, scy3;
141 VARIANT mapx2,mapy2,mapx4,mapy4;
142 m_eagleMapx.ConvertCoordV(&scx1,&scy1,COleVariant(x1),COleVariant(y1),miMapToScreen);
143 m_eagleMapx.ConvertCoordV(&scx3,&scy3,COleVariant(x3),COleVariant(y3),miMapToScreen);
144 m_eagleMapx.ConvertCoordV(&scx1,&scy3,&mapx2,&mapy2,miScreenToMap);
145 m_eagleMapx.ConvertCoordV(&scx3,&scy1,&mapx4,&mapy4,miScreenToMap);
146 double x2=mapx2.dblVal;
147 double y2=mapy2.dblVal;
148 double x4=mapx4.dblVal;
149 double y4=mapy4.dblVal;
150
151 //重画矩形框
152 m_eaglefeature.GetParts().Item(1).RemoveAll(); //除去已有的顶点
153 m_eaglefeature.GetParts().Item(1).AddXY(x1,y1); //添加顶点1
154 m_eaglefeature.GetParts().Item(1).AddXY(x2,y2); //添加顶点2
155 m_eaglefeature.GetParts().Item(1).AddXY(x3,y3); //添加顶点3
156 m_eaglefeature.GetParts().Item(1).AddXY(x4,y4); //添加顶点4
157
158 //更新显示图层
159 m_eaglefeature.Update(); //更新Feature属性
160
161 //发送自定义消息通知CMapXSampleMDIView,该消息由MainFrm接收并传递
162 CDoublePoint point;
163 point.X=m_eaglefeature.GetCenterX();
164 point.Y=m_eaglefeature.GetCenterY();
165 AfxGetMainWnd()->SendMessage(WM_MAPX_EAGLE_FEATURE_MOVE, ButtonFlag, (LPARAM)&point);
166 return true;
167}
168
169
11) 新增一个头文件,用来定义自定义WINDOWS消息,以及两个小结构
// CommonDef.h
2//自定义消息
3#define WM_MAPX_LOAD_NEW_MAP WM_USER+107 //MAPX控件装载新地图
4#define WM_MAPXVIEW_CHANGED WM_USER+109 //MAPX主视图视图更新
5#define WM_MAPX_EAGLE_FEATURE_MOVE WM_USER+108 //MAPX鹰眼图feature框移动
6
7struct CDoubleRect
8{
9 double X1;
10 double X2;
11 double Y1;
12 double Y2;
13};
14
15class CDoublePoint
16{
17public:
18 double X;
19 double Y;
20 CDoublePoint()
21 {
22 X=0.0;
23 Y=0.0;
24 }
25};
26
并在stdafx.h中增加 #include "CommonDef.h"
12) 为了能够处理一Doc多View的情况,即鹰眼图能够引发与Doc关联的所有View的联动, 需要在MapXSampleMDIDoc.h中增加如下定义:
2 double CenterPointX; //鹰眼图矩形框中央点的X坐标
3 double CenterPointY; //鹰眼图矩形框中央点的Y坐标
4
13)为了在主图和鹰眼图之间传递变化触发的消息, 需要修改MainFrm.h 和 MainFrm.cpp, 为它们增加消息转发的功能
// MainFrm.h : CMainFrame 类的接口
2
3class CMainFrame : public CMDIFrameWnd
4{
5protected: // 控件条嵌入成员
6
7 CToolBar m_wndToolBarMap; //MapX的控件条
8 CMapXEagleBar m_wndMapXEagleBar; //MapX 鹰眼窗口
9 COXTabClientWnd m_MTIClientWnd; //MDI的Tab页
10
11// 生成的消息映射函数
12protected:
13 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
14 afx_msg LRESULT OnMapViewChange(WPARAM wParam, LPARAM lParam);
15 afx_msg LRESULT OnMapEagleChange(WPARAM wParam, LPARAM lParam);
16 DECLARE_MESSAGE_MAP()
17};
18
19
// MainFrm.cpp : CMainFrame 类的实现
2 ON_WM_CREATE()
3 ON_MESSAGE(WM_MAPXVIEW_CHANGED, OnMapViewChange)
4 ON_MESSAGE(WM_MAPX_EAGLE_FEATURE_MOVE, OnMapEagleChange)
5END_MESSAGE_MAP()
6
7int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
8{
9 if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
10 return -1;
11
12 //将打开的文档以TAB页方式呈现
13 m_MTIClientWnd.Attach(this,TCS_SINGLELINE|TCS_HOTTRACK);
14
15 //主工具栏
16 if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
17 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
18 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
19 {
20 TRACE0("未能创建工具栏\n");
21 return -1; // 未能创建
22 }
23 //状态栏
24 if (!m_wndStatusBar.Create(this) ||
25 !m_wndStatusBar.SetIndicators(indicators,
26 sizeof(indicators)/sizeof(UINT)))
27 {
28 TRACE0("未能创建状态栏\n");
29 return -1; // 未能创建
30 }
31 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
32 EnableDocking(CBRS_ALIGN_ANY);
33 DockControlBar(&m_wndToolBar);
34
35 //鹰眼栏
36 if (!InitMapXEagleBar())
37 {
38 TRACE0("Failed to create dialog bar m_wndMapXEagleBar!\n");
39 return -1; // fail to create
40 }
41 //MapX的工具栏
42 if (!m_wndToolBarMap.Create(this) ||
43 !m_wndToolBarMap.LoadToolBar(IDR_TOOLBARMAP))
44 {
45 TRACE0("未能创建MapX状态栏\n");
46 return -1; // fail to create
47 }
48 m_wndToolBarMap.SetBarStyle(m_wndToolBarMap.GetBarStyle() |
49 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
50 m_wndToolBarMap.EnableDocking(CBRS_ALIGN_ANY);
51 DockControlBar(&m_wndToolBarMap, AFX_IDW_DOCKBAR_RIGHT);
52
53 return 0;
54}
55
56LRESULT CMainFrame::OnMapViewChange(WPARAM wParam, LPARAM lParam)
57{
58 CDoubleRect* pRect=(CDoubleRect*)lParam;
59 double X1,Y1,X2,Y2; //声明坐标变量
60
61 X1=pRect->X1;
62 Y1=pRect->Y1;
63 X2=pRect->X2;
64 Y2=pRect->Y2;
65
66 m_wndMapXEagleBar.OnMapViewChange(X1,Y1,X2,Y2);
67 return S_OK;
68}
69
70LRESULT CMainFrame::OnMapEagleChange(WPARAM wParam, LPARAM lParam)
71{
72 CDoublePoint* pPoint=(CDoublePoint*) lParam;
73
74 CMapXSampleMDIApp* pApp = (CMapXSampleMDIApp*)AfxGetApp();
75 CMapXSampleMDIDoc* pDoc = (CMapXSampleMDIDoc*)pApp->OpenWndByDocType("MapXSampleMDI");
76
77 if(pDoc==NULL)
78 return S_FALSE;
79
80 pDoc->CenterPointX=pPoint->X;
81 pDoc->CenterPointY=pPoint->Y;
82 pDoc->UpdateAllViews(NULL);
83 return S_OK;
84}
85
86
Last Updated: Tuesday, May 17, 2005 21:48:05
eXcel Wong