ReyNold
路人甲
路人甲
  • 注册日期2005-05-22
  • 发帖数8
  • QQ
  • 铜币140枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2658回复:5

VC+AE制作鹰眼图问题!

楼主#
更多 发布于:2007-11-25 20:45
<P>本人今天写了一段用AE+VC的鹰眼图程序,但是总是在一条语句那出问题,请大虾指导下,谢谢。</P>
<P>前面部分的代码如下:(在mapcontrol的OnExtentUpdatedMapctrl消息中)</P>
<P> IEnvelopePtr ipEnvelope;<BR> IGraphicsContainerPtr ipGraph;<BR> IActiveViewPtr ipActiveView;</P>
<P> HRESULT hr=m_ipMapControl2->get_ActiveView(;ipActiveView);<BR> if(FAILED(hr)) return;<BR> ipGraph=ipActiveView;<BR> hr=ipGraph->DeleteAllElements();<BR> if(FAILED(hr)) return;</P>
<P> IElementPtr ipElement(CLSID_RectangleElement);<BR> IRectangleElementPtr ipRectElement;<BR> ipElement=ipRectElement;<BR> IGeometryPtr ipGeometry;<BR> hr=m_ipMapControl->get_Extent(;ipEnvelope);<BR> if(FAILED(hr)) return;<BR>  ipGeometry=ipEnvelope.GetInterfacePtr();<BR> hr=ipElement->put_Geometry(ipGeometry);<BR> if(FAILED(hr)) return;</P>
<P>总是在hr=ipElement->put_Geometry(ipGeometry);这出错,不知道为什么?该怎么写呢?<BR></P>
喜欢0 评分0
ReyNold
路人甲
路人甲
  • 注册日期2005-05-22
  • 发帖数8
  • QQ
  • 铜币140枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-11-25 21:26
<P>刚刚看一本COM书的时候得到灵感了,问题解决。但是本着造福大家的思想,我把我写好通过的代码贴给大家。</P>
<P>void CAlgoTestView::OnExtentUpdatedMapctrl(const VARIANT FAR; displayTransformation, BOOL sizeChanged, const VARIANT FAR; newEnvelope) <BR>{<BR> IEnvelopePtr ipEnvelope;<BR> IGraphicsContainerPtr ipGraph;<BR> IActiveViewPtr ipActiveView;<BR> IMapPtr ipMap;</P>
<P> HRESULT hr=m_ipMapControl2->get_ActiveView(;ipActiveView);<BR> if(FAILED(hr)) return;<BR> ipGraph=ipActiveView;<BR> hr=ipGraph->DeleteAllElements();<BR> if(FAILED(hr)) return;</P>
<P> IElementPtr ipElement;<BR> IRectangleElementPtr ipRectElement(CLSID_RectangleElement);//相当于vb中的ipRectElement= new RectangleElement<BR> ipElement=ipRectElement;<BR> IGeometryPtr ipGeometry;<BR> hr=m_ipMapControl->get_Extent(;ipEnvelope);<BR> if(FAILED(hr)) return;<BR>  ipGeometry=ipEnvelope.GetInterfacePtr();<BR> hr=ipElement->put_Geometry(ipGeometry);<BR> if(FAILED(hr)) return;</P>
<P> IRgbColorPtr ipRgbColor(CLSID_RgbColor);<BR> ipRgbColor->put_RGB(RGB(255,0,0));<BR> ipRgbColor->put_Transparency(255);</P>
<P> ILineSymbolPtr ipLineSymbol(CLSID_SimpleLineSymbol);//相当于vb中的ipLineSymbol= new SimpleLineSymbol<BR> ipLineSymbol->put_Width(1);<BR> ipLineSymbol->put_Color(ipRgbColor);</P>
<P> ipRgbColor->put_RGB(RGB(255,0,0));<BR> ipRgbColor->put_Transparency(0);</P>
<P> IFillSymbolPtr ipFillSymbol(CLSID_SimpleFillSymbol);<BR> ipFillSymbol->put_Color(ipRgbColor);<BR> ipFillSymbol->put_Outline(ipLineSymbol);</P>
<P> IFillShapeElementPtr ipFillShapeElement;<BR> ipFillShapeElement=ipElement;<BR> ipFillShapeElement->put_Symbol(ipFillSymbol);<BR> ipGraph->AddElement(ipElement,0);<BR> ipActiveView->Refresh();<BR> <BR>}</P>
<P>虽然还不是十分完美,但是基本的功能已经实现了。</P>
举报 回复(0) 喜欢(0)     评分
ReyNold
路人甲
路人甲
  • 注册日期2005-05-22
  • 发帖数8
  • QQ
  • 铜币140枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-11-25 21:28
<P>加上下面两段就可以实现鹰眼控件和主控件的联动。</P>
<P>void CAlgoTestView::OnMouseDownMapctrl2(long button, long shift, long X, long Y, double mapX, double mapY) <BR>{<BR> if (2==button)<BR> {<BR>  IPointPtr ipPoint(CLSID_Point);<BR>  IMapPtr ipMap;<BR>  ipPoint->put_X(mapX);<BR>  ipPoint->put_Y(mapY);</P>
<P>  IEnvelopePtr ipEnvelope;<BR>  m_ipMapControl2->TrackRectangle(;ipEnvelope);<BR>  m_ipMapControl->put_Extent(ipEnvelope);<BR> }<BR>}</P>
<P>void CAlgoTestView::OnMouseMoveMapctrl2(long button, long shift, long X, long Y, double mapX, double mapY) <BR>{<BR> if (1==button)<BR> {<BR>  IPointPtr ipPoint(CLSID_Point);<BR>  IMapPtr ipMap;<BR>  ipPoint->put_X(mapX);<BR>  ipPoint->put_Y(mapY);<BR>  <BR>  IEnvelopePtr ipEnvelope;<BR>  m_ipMapControl->get_Extent(;ipEnvelope);<BR>  ipEnvelope->CenterAt(ipPoint);<BR>  m_ipMapControl->put_Extent(ipEnvelope);<BR>  <BR> }<BR>}</P>
举报 回复(0) 喜欢(0)     评分
stepwin
路人甲
路人甲
  • 注册日期2007-03-14
  • 发帖数15
  • QQ
  • 铜币147枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-12-06 11:25
<P>更加简单的实现</P>
<P>procedure TFrmMain.MapMainAfterDraw(ASender: TObject; Display: OleVariant;<BR>  viewDrawPhase: Integer);<BR>var<BR>  FillSymbol: IFillSymbol;<BR>  pColor: IColor;<BR>  outline: ILineSymbol;<BR>  flag: WordBool;<BR>  symbol: OleVariant;<BR>begin<BR>  //红框<BR>  pColor:=CoRgbColor.create as IColor;<BR>  outline:= CoSimpleLineSymbol.create as ILineSymbol;<BR>  pColor.Set_RGB(RGB(255, 0, 0));<BR>  pColor.Set_Transparency(255);<BR>  outline.Set_Color(pColor);<BR>  outline.Set_Width(1.5);</P>
<P>  //填充<BR>  pColor:=CoRgbColor.create as IColor;<BR>  pColor.Set_RGB(RGB(0,0,0));<BR>  pColor.Set_Transparency(0);<BR>  FillSymbol:=CoSimpleFillSymbol.create as IFillSymbol;<BR>  FillSymbol.Set_Color(pColor);<BR>  FillSymbol.Set_Outline(outline);</P>
<P>  //画鹰眼<BR>  MapEye.Refresh;<BR>  symbol:=FillSymbol;<BR>  MapEye.DrawShape(mapMain.Extent,symbol);<BR>end;</P>
举报 回复(0) 喜欢(0)     评分
sunlw78
路人甲
路人甲
  • 注册日期2007-09-06
  • 发帖数8
  • QQ
  • 铜币159枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2009-04-15 09:09
<P>这样的帖子怎么没人支持啊!</P>
举报 回复(0) 喜欢(0)     评分
sunlw78
路人甲
路人甲
  • 注册日期2007-09-06
  • 发帖数8
  • QQ
  • 铜币159枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2009-04-16 10:06
<P>这个程序,应该是针对对话框的吧,如果要是用单文档来做,恐怕非常麻烦了,不知道楼主是否做过啊?</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部