Table of Contents 9.3 vs 9.4

2801
10
Jump to solution
10-27-2009 09:48 AM
by Anonymous User
Not applicable
Original User: maplogic

I am trying to find more information about how the ArcMap Table of Contents (IContentsView) has changed in 9.4 compared to older versions.

Specifically, can developers still add custom tabs in the Table of Contents?  If so, how is this done?  Code that worked to add a custom tab in older versions no longer seems to work. 

I've also noticed that a Table of Contents Tab no longer exists in the ArcMap options dialog.

I would appreciate any insider information about this.  Does ESRI want developers to use IDockableWindow instead?

Thanks,
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Your custom toc class has to implement IContentsView3 rather than IContentsView to return the bitmap and tooltip properties. The doc and sample has been updated for Beta 2 but here's the basic implementation for the extra properties. Refer to the 9.3 sample for the remaining code.

C#
        public int Bitmap
        {
          get
          {
            string bitmapResourceName = GetType().Name + ".bmp";
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(GetType(), bitmapResourceName);
            bmp.MakeTransparent(bmp.GetPixel(1, 1)); //alternatively use a .png with transparency
            return bmp.GetHbitmap().ToInt32();
          }
        }

        public string Tooltip
        {
          get { return "Layer Types (C#)"; }
        }


VB.Net
    Public ReadOnly Property Bitmap() As Integer Implements IContentsView3.Bitmap
        Get
            Dim bitmapResourceName As String = Me.GetType().Name + ".bmp"
            Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(Me.GetType(), bitmapResourceName)
            bmp.MakeTransparent(bmp.GetPixel(1, 1)) 'alternatively use a .png with transparency
            Return bmp.GetHbitmap().ToInt32()
        End Get
    End Property

    Public ReadOnly Property Tooltip() As String Implements IContentsView3.Tooltip
        Get
            Return "Layer Types (VB.NET)"
        End Get
    End Property

The bitmap is 16x16.

View solution in original post

0 Kudos
10 Replies
RalfGottschalk
Esri Contributor
Hi Maplogic,

Developers can still add custom tabs in the Table of Contents, but they would not show up as tabs, they would be the buttons that you currently see in the ArcMap TOC.  Your old code should just work, and all you should need to do is use IContentsView3, which has the Bitmap and Tooltip property so that your button in the TOC will have an image.  Make sure that you have done what you need to do to upgrade your code so it works with 9.4. 

see this link

I spoke with someone on when you should be using a ContentsView over a DockableWindow, and our recommendation is that you should create a ContentsView when you need to work with Layers in the Map document, otherwise your should be creating a DockableWindow. 

Regarding the Table of Contents tab in the options dialog, it looks like you can see some of the options by clicking the options button in the TOC.
0 Kudos
by Anonymous User
Not applicable
Original User: Grieck

Hello,

It appears that the IContentsView3.Bitmap is read only. Is the intention to allow developers to assign a bitmap for the TOC image?  Same goes for Tooltip. 

IContentsView3 pContView = pMxDoc.CurrentContentsView as IContentsView3;
pContView.Bitmap = 8;
pContView.Tooltip = "OSPInSight";

Property or indexer 'ESRI.ArcGIS.ArcMapUI.IContentsView3.Bitmap' cannot be assigned to -- it is read only

Property or indexer 'ESRI.ArcGIS.ArcMapUI.IContentsView3.Tooltip' cannot be assigned to -- it is read only

G
0 Kudos
by Anonymous User
Not applicable
Your custom toc class has to implement IContentsView3 rather than IContentsView to return the bitmap and tooltip properties. The doc and sample has been updated for Beta 2 but here's the basic implementation for the extra properties. Refer to the 9.3 sample for the remaining code.

C#
        public int Bitmap
        {
          get
          {
            string bitmapResourceName = GetType().Name + ".bmp";
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(GetType(), bitmapResourceName);
            bmp.MakeTransparent(bmp.GetPixel(1, 1)); //alternatively use a .png with transparency
            return bmp.GetHbitmap().ToInt32();
          }
        }

        public string Tooltip
        {
          get { return "Layer Types (C#)"; }
        }


VB.Net
    Public ReadOnly Property Bitmap() As Integer Implements IContentsView3.Bitmap
        Get
            Dim bitmapResourceName As String = Me.GetType().Name + ".bmp"
            Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(Me.GetType(), bitmapResourceName)
            bmp.MakeTransparent(bmp.GetPixel(1, 1)) 'alternatively use a .png with transparency
            Return bmp.GetHbitmap().ToInt32()
        End Get
    End Property

    Public ReadOnly Property Tooltip() As String Implements IContentsView3.Tooltip
        Get
            Return "Layer Types (VB.NET)"
        End Get
    End Property

The bitmap is 16x16.
0 Kudos
by Anonymous User
Not applicable
Original User: rlwatson

Thanks for the responses from the ESRI guys.  I had the same problem and now the solution is clear.

Maybe all of this documentation comes in beta 2.  Right now, it is a bit of a struggle trying to figure out the list of things that I need to do in order to port a very large custom application from 9.3.1. to 9.4.
0 Kudos
GregRieck
Frequent Contributor
I think I'm still not understanding how I can "set" the bitmap image of this method when it doesn't have a "set" property. Even the help documents it as a "get" only method.  What exactly do you mean by implement IContentsView3?

I have done the following:
IContentsView3 pContView = pMxDoc.CurrentContentsView as IContentsView3;

which exposes pContView.Bitmap and pContView.Tooltip
Yet anything I try to do with these two methods reports back that they are read only.


rlwatson - Do you have working code that you could post?
0 Kudos
by Anonymous User
Not applicable
Original User: sean_jones

Grieck,

Take a look at the 9.3 help page and associated sample to see how it was done at 9.3.
http://resources.esri.com/help/9.3/ArcGISDesktop/dotnet/260508ab-5114-40eb-a315-29d7110e63b9.htm

For 9.4 we turned the tabs into buttons on the TOC toolbar. To support this you have to implement IContentsView3, which exposes the extra properties, in your custom class.

The 9.3 sample will still work in 9.4 once you fix up the references, compile and register (esriregasm), you just wont get an icon.

You cant change the bitmap or tooltip at run time.

@rlwatson: Most of the SDK doc should be complete at beta2 including migration paths. Once you get beta2 (i dont have a date) let us know asap if it doesnt help you migrate your code.
0 Kudos
GregRieck
Frequent Contributor
Thanks Sean, I got it working. So, is there no location within ArcMap to remove a custom Contents View? In 9.3 you can choose to not have some visible in the TOC.
0 Kudos
by Anonymous User
Not applicable
Original User: sean_jones

So, is there no location within ArcMap to remove a custom Contents View?

Not yet but were working on it.
0 Kudos
MiguelParedes
Esri Contributor
:confused:Howdy all,
I'm trying to figure out how to set the font of my TOC, but the Tools > Options...>  Options form does no longer have a 'Table of Contents' tab for selecting the Appearance.  There is an options button, but it lacs the appearance.  Is this because this is still in Beta?  Or is there another way of setting the appearance of the TOC?
Thanks in advance.
Miguel
0 Kudos