Dim pTextElement As ITextElement Set pTextElement = pElement Dim pElementProperties As IElementProperties3 Set pElementProperties = pElement Dim pEnvelope As IEnvelope Set pEnvelope = New Envelope pElement.QueryBounds pMxDocument.ActiveView.ScreenDisplay, pEnvelope Dim pPoint As IPoint 'エレメントのアンカー位置を取得 Select Case pElementProperties.AnchorPoint Case esriTopLeftCorner '左上 Set pPoint = pEnvelope.LowerLeft Case esriTopMidPoint '中央上 Set pPoint = New Point pPoint.X = pEnvelope.XMin + pEnvelope.Width / 2 pPoint.Y = pEnvelope.YMax Case esriTopRightCorner '右上 Set pPoint = pEnvelope.LowerLeft Case esriLeftMidPoint '左中央 Set pPoint = New Point pPoint.X = pEnvelope.XMax pPoint.Y = pEnvelope.YMin + pEnvelope.Height / 2 Case esriCenterPoint '中心 Dim pArea As IArea Set pArea = pEnvelope Set pPoint = pArea.Centroid Case esriRightMidPoint '右中央 Set pPoint = New Point pPoint.X = pEnvelope.XMin pPoint.Y = pEnvelope.YMin + pEnvelope.Height / 2 Case esriBottomLeftCorner '左下 Set pPoint = pEnvelope.LowerLeft Case esriBottomMidPoint '中央下 Set pPoint = New Point pPoint.X = pEnvelope.XMin + pEnvelope.Width / 2 pPoint.Y = pEnvelope.YMin Case esriBottomRightCorner '右下 Set pPoint = pEnvelope.LowerRight End Select 'テキスト シンボルのアンカー配置位置 Dim pTextSymbol As ITextSymbol Set pTextSymbol = pTextElement.Symbol Debug.Print pTextSymbol.HorizontalAlignment, pTextSymbol.VerticalAlignment pTextSymbol.HorizontalAlignment = esriTHALeft pTextSymbol.VerticalAlignment = esriTVABottom pTextElement.Symbol = pTextSymbol pMxDocument.ActiveView.Refresh
テキスト エレメントのサイズと位置
2016/9/1 (木)