Delphi版 ArcEngine 创建MapSurround对象

function CreateSurround(pUID: UID; pEnv: IEnvelope; strName: string; pPageLayout: IPageLayout): IMapSurround;
var
   pGraphicsContainer: IGraphicsContainer;
   pActiveView: IActiveView;
   pMapSurroundFrame: IMapSurroundFrame;
   pMapSurround: IMapSurround;
   pMapFrame: IMapFrame;
   pElement : IElement;
   pMap     : IMap;
begin

   pGraphicsContainer := pPageLayout as IGraphicsContainer;
   pActiveView := pPageLayout as IActiveView;
   pMap := pActiveView.FocusMap;

   pMapFrame := pGraphicsContainer.FindFrame(pMap) as IMapFrame;
   //当 地图框架 被删除后,必须做异常处理
   if pMapFrame = nil then
      Exit(nil);

   pMapSurroundFrame := pMapFrame.CreateSurroundFrame(pUID, nil);
   pMapSurroundFrame.MapSurround.Name := strName;

   pElement := pMapSurroundFrame as IElement;
   pElement.Geometry := pEnv as IGeometry;

   pGraphicsContainer.AddElement(pElement, 0);

   Result := pMapSurroundFrame.MapSurround;
end;
posted on 2009-03-19 11:16  知真道  阅读(602)  评论(0编辑  收藏  举报