How do you add a BaseCommand to a custom BaseToolbar as an icon and text. This is not an Add-In, it's the old way of doing buttons and toolbars even though it's version 10 of ArcMap.

Cheers

link|improve this question

76% accept rate
feedback

2 Answers

up vote 1 down vote accepted

I didn't try the solution in the thread below but it looks correct to me: How to show caption and icon for basecommand

Depending on how your toolbar is setup, the check for Enabled() can happen frequently. You may want to add a boolean flag to keep the SetAsIconAndText() function from constantly running.

link|improve this answer
I think it should probably be set up through NewDocument method of a bland Extension class. (I tried to find an example of this question on the forums but obviously used the wrong search words - nice find!) – Vidar Feb 14 at 13:45
feedback

You need to create a toolbar class, IToolbarDef, to reference your BaseCommand icons to. Then create a resource bitmap and reference it in your BaseCommand class, see example below:

Public Sub New()
        MyBase.New()


        MyBase.m_category = "Developer Samples"
        MyBase.m_caption = "Export Active View VisualBasic .NET"
        MyBase.m_message = "Exports the Active View using VisualBAsic .NET"
        MyBase.m_toolTip = "Export PDFs"
        MyBase.m_name = Me.GetType().Name + ""

        Try
            'load the bitmap resource (the icon for this tool).
            Dim bitmapResourceName As String = Me.GetType().Name + ".bmp"
            MyBase.m_bitmap = New Bitmap(Me.GetType(), bitmapResourceName)
        Catch ex As Exception
            System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap")
        End Try


    End Sub
link|improve this answer
This only shows the icon - but I also need text next to it as well. I think it has something to do with: ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconAndText – Vidar Feb 9 at 9:03
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.