How do I programmatically get the position and size of ArcMap's data view?

599
5
03-03-2017 01:26 PM
New Contributor III

I'm needing to programmatically display a form at the upper left position of ArcMap the data view.

How do I get the X/Y position?

Tags (1)
Reply
0 Kudos
5 Replies
MVP Esteemed Contributor

examine the properties and the code examples in the dataframe section in arcpy

Reply
0 Kudos
New Contributor III

I'm working with ArcGIS 10.2.2 version and ArcObjects. I haven't used Python at all.

Reply
0 Kudos
MVP Esteemed Contributor

https://community.esri.com/community/developers/gis-developers/arcobjects-sdk?sr=search&searchId=69f...‌ might be a good place to move your thread too... generic gis is probably going to of little help for you especially given the legacy/older version of arcmap

Reply
0 Kudos
New Contributor III

Thanks Dan, I will take that under consideration on future postings.

Reply
0 Kudos
New Contributor III

OK... I found some code that got me access to the Standard toolbar within ArcMap.  Just a little modifications to obtain the starting location of the toolbar which I can use anchor my form until it's closed.

'

' --- Get coordinates of the upper left corner of the Standard Bar (location)

'     This will be used to position the Move Post form

'

Dim documentBars As ICommandBars = gApplication.Document.CommandBars 'app is a reference to IApplication

Dim barID As UID = New UIDClass

barID.Value = "{5DEB1DB8-C2A9-11D1-B9A2-080009EE4E51}"

Dim bar As ICommandItem = documentBars.Find(barID)

Dim windowPos As IWindowPosition = CType(bar, IWindowPosition)

'If windowPos.State = esriWindowState.esriWSFloating Then

' MsgBox("Standard toolbar is floating.")

'Else

' MsgBox("Standard toolbar is docked.")

'End If

'

' --- Call create Move Post form

'

gfrmMovePost = New MovePost

'

' --- Change the location of the form

'

gfrmMovePost.Top = windowPos.Top

gfrmMovePost.Left = windowPos.Left

'

' --- Call form and display it

'

gfrmMovePost.Show()

Reply
0 Kudos