Delphi ArcEngine 创建指北针

function InsertNorthArrow(aePageLayoutControl: TPageLayoutControl; iStyle: SmallInt): Boolean;
var
   pPageLayout: IPageLayout;
   pMap     : IMap;
   pActiveMap: IActiveView;
   pGraphicContainer: IGraphicsContainer;
   pMapFrame: IMapFrame;
   pMapSurround: IMapSurround;
   pMapSurroundFrame: IMapSurroundFrame;
   pUID     : UID;

   pEnvelope: IEnvelope;

   pNorthArrow: IMarkerNorthArrow;
   pCharacterMarkerSymbol: ICharacterMarkerSymbol;
begin
   pUID := CoUID.Create as UID;
   pUID.Value := 'esriCarto.MarkerNorthArrow';

   pPageLayout := aePageLayoutControl.PageLayout;
   pActiveMap := pPageLayout as IActiveView;

   aePageLayoutControl.TrackCancel.Reset;
   pEnvelope := aePageLayoutControl.TrackRectangle;

   if (pEnvelope.IsEmpty) or (pActiveMap = nil) then
      Exit(False);

   pMapSurround := CreateSurround(pUID, pEnvelope, '指北针', pPageLayout);//这个函数并非 ae 自带的,是自己写的,请参考另外一个随笔

   // Delphi版 ArcEngine 创建MapSurround对象

   if pMapSurround = nil then
      Exit(False);

   pNorthArrow := pMapSurround as IMarkerNorthArrow;
   pCharacterMarkerSymbol := pNorthArrow.MarkerSymbol as ICharacterMarkerSymbol;
   pCharacterMarkerSymbol.CharacterIndex := iStyle;

   pNorthArrow.MarkerSymbol := pCharacterMarkerSymbol;
   pActiveMap.PartialRefresh(esriViewGraphics, nil, nil);

   Result := True;
end;
原文地址:https://www.cnblogs.com/chinacodegear/p/1416416.html