Skip to content

Instantly share code, notes, and snippets.

@KohsukeHada
Last active June 8, 2021 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KohsukeHada/6183021 to your computer and use it in GitHub Desktop.
Save KohsukeHada/6183021 to your computer and use it in GitHub Desktop.
レイアウト ビューでマウス クリック地点の用紙座標とマップ座標の両方を取得する方法
'レイアウト ビューでマウス クリック地点の用紙座標とマップ座標の両方を取得する方法
Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
Dim pMxDocument As IMxDocument
Set pMxDocument = ThisDocument
Dim pPoint As IPoint
Set pPoint = pMxDocument.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)
Debug.Print "FormPoint:", pPoint.x, pPoint.y '用紙座標
Dim pGCS As IGraphicsContainerSelect
Set pGCS = pMxDocument.PageLayout
Dim pMapFrame As IMapFrame
Set pMapFrame = pGCS.SelectedElement(0) '事前にマップ フレームを選択状態にしておくこと
Dim pActiveView As IActiveView
Set pActiveView = pMapFrame.Map
Dim pMapPoint As IPoint
Set pMapPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)
Debug.Print "MapPoint:", pMapPoint.x, pMapPoint.y 'マップ座標
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment