Select to view content in your preferred language

ArcObjects Books for 10.0 (where?????)

3502
13
10-03-2012 08:24 PM
AbelPerez
Frequent Contributor
I am looking to create from scratch an ArcMap extension using .NET. Looking for books that detail the process. So far I have found nothing that will help me become adjusted to the .NET way of creating an extension. I have some help from tech support and some list users but wanted something more as an official reference. Anyone know of any good books I can take a look at?

As a side note I think I can sludge my way through and create a sample extension. But what I want to do is understand each step of the process. For example there are several extension types I can create and I can add several types of buttons to my toolbar. I have yet to find a good reference that explains each option and where and why to use each type.

any help is appreciated.

AGP
0 Kudos
13 Replies
AbelPerez
Frequent Contributor
ok I've been looking at it. I'm making progress. I'm not certain about the turning the extension off/on as I don't remember doing that in the VB6 model. There has got to be one setting at the toolbar level rather than the button level.

AGP
0 Kudos
AlexanderGray
Honored Contributor
Buttons can be moved from one toolbar to another very easily, go into customize mode, move the button to another toolbar.  Having the enabled property on the toolbar level wouldn't make sense for that reason.  The property is on the command.
0 Kudos
AbelPerez
Frequent Contributor
You are right. I guess I never paid attention to that. I thought my toolbar was locked in.

AGP
0 Kudos
AbelPerez
Frequent Contributor
Ok I think I get it now but information is really scattered and unless you know what you are looking for its hit and miss. So in VB6 I used to use the ICommand_Enabled event in each command for enabling/disabling the button. from what I have read, you now have to over-ride the Enabled() event of the button. So really I keep local variables for my basic elements, then assign them at OnCreate, and toggle the button at Enabled(). For each command button something like:

    Private m_application As IApplication
    Private m_mxdocument As IMxDocument
    Private m_map As IMap             
    Private m_pExt As IExtensionConfig 

    Public Overrides Sub OnCreate(ByVal hook As Object)
        If Not hook Is Nothing Then
            m_application = CType(hook, IApplication)                            
            m_mxdocument = CType(m_application.Document, IMxDocument)                                       
            m_map = m_mxdocument.ActivatedView.FocusMap                                                     
            m_pExt = CType(m_application.FindExtensionByName("myExt.extMain"), IExtensionConfig) 

            'blah
        End If
    End Sub

    Public Overrides ReadOnly Property Enabled() As Boolean
        Get
            m_mxdocument = CType(m_application.Document, IMxDocument)        
            m_map = m_mxdocument.ActivatedView.FocusMap            

            If (m_pExt IsNot Nothing) Then
                If (m_pExt.State = esriExtensionState.esriESEnabled And m_map.LayerCount > 0) Then
                    Enabled = True
                Else
                    Enabled = False
                End If
            Else
                Enabled = False
            End If
        End Get
    End Property


Does that look about right? Couple things..In the samples I have looked at they use ActivatedView instead of ActiveView. I've read the documentation and still dont get how you use each one or how they are different. Also, notice above that in the Enabled routine I am getting a reference to the document and map again, even though I have already got them at the OnCreate event. Well it turns out an issue I had in my VB6 project also happens here. There are two ways to open a map 1)by double-clicking on the MXD in Windows Explorer and 2)by selecting the map through the ArcMap Dialog box that pops up when you open up ArcMap on its own. Well when you do #2 the variables that hold the document and map get lost. You have to re-get them on the Enabled event. Why does this happen? Is it a bug? ESRI Tech support knows about it as I reported it some time ago. If it is a bug it has not been resolved as of 10.0. I haven't tested with 10.1 as I haven't moved to that yet.

So there it is. Please feel free to comment as to my progress. Its slow but in the end it will take me through another 10 years I hope with this extension.

AGP
0 Kudos