Last active
June 8, 2021 14:14
-
-
Save KohsukeHada/6183021 to your computer and use it in GitHub Desktop.
レイアウト ビューでマウス クリック地点の用紙座標とマップ座標の両方を取得する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'レイアウト ビューでマウス クリック地点の用紙座標とマップ座標の両方を取得する方法 | |
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