Select to view content in your preferred language

Migrating from 9.3.1 to 10 may be impossible if you use mapcontrols in ArcMap

942
6
01-26-2011 06:32 AM
AlexanderGray
Honored Contributor
Hello,
Looks like our organization has been left high and dry.  We are converting 9.3.1 ArcObjects code for an ArcMap customization that uses overview maps on a seperate form.  These overview maps are ESRI MapControls.  They only run inside ArcMap.  At ArcGIS 9.3.1 it is possible to add these map controls to your VS project.  After migrating to ArcGIS 10, to edit the mapcontrols in VS studio you now need an ArcGIS Engine SDK license, even if the application is not Engine and even if previous versions of ArcGIS desktop did not require this. 
We are left a choice between rolling back to ArcGIS 9.3.1 or acquiring 8 EDN licenses and rolling back to ArcGIS 9.3.1 until we can get the licenses.
That is my rant.
0 Kudos
6 Replies
RuchiraWelikala
Regular Contributor
The company I'm currently working for is looking to upgrade to 10 in the near future and this will definitely be a deterrent.
Wonder what motivated this requirement for an additional license for map controls...
0 Kudos
AlexanderGray
Honored Contributor
This is turning out to be a major issue for me.
I have a bunch of unit tests that leverage the map control.  Basically I have code that makes custom graphics to put on the map and I want to run tests to make sure they are always correct.  I have unit tests that have a mapcontrol, draws the graphics to the map and exports the map to an image, I can then compare the image to the expected image as a test.  This new mapcontrol licensing requirement make all these tests unusable.  It is hard enough to write tests for ArcMap, now it is just impossible.
0 Kudos
NeilClemmons
Honored Contributor
I agree that changing the licensing for the MapControl a decade after its release isn't a good thing.  However, you probably don't need the control to perform those unit tests.  Use the IMapDocument interface to open a document you've created for the tests and get the map reference from it.  You should be able to draw your graphics and export them just fine.  We have several programs that process directories full of map documents and export images and pdfs at various extents and scales withiout ever opening them for display.

Also, it is possible to create your own map control.  The IActiveView interface has an Activate method that will allow you to associate the view with any control that has a drawing context (picture box, panel, etc).  After calling Activate, you will need to call the Draw method inside that control's Paint event.  I haven't bothered to try this in .NET yet but we created such a control in VB6 way back in 8.0.1 when the MapControl had yet to be released.  I know this would mean extra development effort, but it is possible and could serve as a workaround to having to purchase another development license.
0 Kudos
AlexanderGray
Honored Contributor
Thanks Neil,
The idea of creating my own custom map control is very helpful.  I managed to add a raster layer to a map and set the display to a form.  The only problem I get is the refresh.  I put the activeview.draw call in the on_paint event but it seams after the form loads or if it loses focus or if I resize, it only draws the image if I tinker with the scroll bars that show up on my form...
I did all the license stuff in the project start-up and shutdown.
0 Kudos
NeilClemmons
Honored Contributor
I managed to find time to give this a quick try in .NET.  I placed a Panel on a form to use as the map canvas.  Here's the code I added to the form class.  I didn't have time to run any real tests or create any custom tools to zoom, pan, etc. but it seems to work fairly well.  The scroll bars don't work properly - clicking the arrows pans the map but grabbing the scroll bar with the mouse doesn't.

Public Class MapDialog

    Private m_activeView As IActiveView

    Private Sub LoadMapButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadMapButton.Click
        Try
            Dim path As String = "C:\Development\ApplicationTest\Mxd\Quantico.mxd"

            Dim mapDoc As IMapDocument = New MapDocument
            mapDoc.Open(path)

            Dim map As IMap = mapDoc.Map(0)

            Dim activeView As IActiveView = DirectCast(map, IActiveView)
            activeView.Activate(Panel1.Handle.ToInt32)

            m_activeView = activeView
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub

    Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        If m_activeView Is Nothing Then Return

        m_activeView.Draw(Panel1.CreateGraphics.GetHdc.ToInt32, Nothing)
    End Sub

End Class
0 Kudos
AlexanderGray
Honored Contributor
Thanks Neil,
The creategraphics is the part I got wrong.  I was passing the handle of the control to the draw.  That is a level deeper than I usually work at.
0 Kudos