IContentView3 Problem

2554
2
01-24-2012 09:46 AM
CarlTremblay
New Contributor
Hello,
        I got a problem with IContentView3. I created a custom crontrol that implements IContentView3.
When I Add that ContentView with the AddContentsView method, I Got a system.NotImplementedException : Method or operation not implemented.
AddContentsView method takes has an IContentView parameter. Do I have to cast the IContentView3 control ?
Thank you verru much ...

  Dim ContentsView As ESRI.ArcGIS.ArcMapUI.IContentsView
  ContentsView = New ESRI.ArcGIS.ArcMapUI.TOCDisplayView

  Dim ContentsViewEdit As ESRI.ArcGIS.ArcMapUI.IContentsViewEdit
  ContentsViewEdit = DirectCast(VDQ.SDDI.EsriLib.ArcObjects.IU.ArcMap.EnvironnementArcMap.Instance.Application.Document,    ESRI.ArcGIS.ArcMapUI.IContentsViewEdit)
  ContentsView = New MyContentView    <---- IContentView3 Control
  ContentsViewEdit.AddContentsView(ContentsView)  <----------------------- System.NotImplementedException
...


Public Class MyContentView   
    Implements ESRI.ArcGIS.ArcMapUI.IContentsView3

    Private Declare Ansi Function ShowWindow Lib "user32" (ByVal hwnd As Int32, ByVal nCmdShow As Int32) As Int32

    Private Const SW_HIDE As Integer = 0
    Private Const SW_SHOW As Integer = 9  

#Region "Variables"
    Private m_UserControl As VDQ.SDDI.Localisation.IU.Windows.Localisation
#End Region

#Region "Conctructeur"
    Public Sub New()
        m_UserControl = New VDQ.SDDI.Localisation.IU.Windows.Localisation(VDQ.SDDI.EsriLib.ArcObjects.IU.ArcMap.ContexteApplication.Instance)
    End Sub
#End Region

    Public Sub Activate(parentHWnd As Integer, Document As ESRI.ArcGIS.ArcMapUI.IMxDocument) Implements IContentsView.Activate, IContentsView2.Activate, IContentsView3.Activate
        ShowWindow(m_UserControl.Handle.ToInt32, SW_SHOW)
    End Sub

    Public Sub AddToSelectedItems(item As Object) Implements IContentsView.AddToSelectedItems, IContentsView2.AddToSelectedItems, IContentsView3.AddToSelectedItems

    End Sub

    Public Sub BasicActivate(parentHWnd As Integer, Document As ESRI.ArcGIS.Framework.IDocument) Implements IContentsView2.BasicActivate, IContentsView3.BasicActivate

    End Sub

    Public Property ContextItem As Object Implements IContentsView.ContextItem, IContentsView2.ContextItem, IContentsView3.ContextItem
        Get
            Return Nothing
        End Get
        Set(value As Object)

        End Set
    End Property

    Public Sub Deactivate() Implements IContentsView.Deactivate, IContentsView2.Deactivate, IContentsView3.Deactivate
        ShowWindow(m_UserControl.Handle.ToInt32, SW_HIDE)
    End Sub

    Public ReadOnly Property hWnd As Integer Implements IContentsView.hWnd, IContentsView2.hWnd, IContentsView3.hWnd
        Get
            Return m_UserControl.Handle.ToInt32
        End Get
    End Property

    Public ReadOnly Property Name As String Implements IContentsView.Name, IContentsView2.Name, IContentsView3.Name
        Get
            Return "Localisation"
        End Get
    End Property

    Public WriteOnly Property ProcessEvents As Boolean Implements IContentsView.ProcessEvents, IContentsView2.ProcessEvents, IContentsView3.ProcessEvents
        Set(ByVal value As Boolean)

        End Set
    End Property

    Public Sub Refresh(item As Object) Implements IContentsView.Refresh, IContentsView2.Refresh, IContentsView3.Refresh

    End Sub

    Public Sub RemoveFromSelectedItems(item As Object) Implements IContentsView.RemoveFromSelectedItems, IContentsView2.RemoveFromSelectedItems, IContentsView3.RemoveFromSelectedItems

    End Sub

    Public Property SelectedItem As Object Implements IContentsView.SelectedItem, IContentsView2.SelectedItem, IContentsView3.SelectedItem
        Get
            Return Nothing
        End Get
        Set(value As Object)

        End Set
    End Property

    Public Property ShowLines As Boolean Implements IContentsView.ShowLines, IContentsView2.ShowLines, IContentsView3.ShowLines
        Get

        End Get
        Set(value As Boolean)

        End Set
    End Property

      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)) 'Utilise un png aléatoire avec transparence
            Return bmp.GetHbitmap().ToInt32()

        End Get
    End Property

     Public ReadOnly Property Tooltip As String Implements IContentsView3.Tooltip
        Get
            Return "Localisation"
        End Get
    End Property

    Public Property Visible As Boolean Implements IContentsView.Visible, IContentsView2.Visible, IContentsView3.Visible
        Get
            Return True
        End Get
        Set(value As Boolean)

        End Set
    End Property
End Class
0 Kudos
2 Replies
by Anonymous User
Not applicable
Carl,
The contents view has changed a bit for ArcGIS 10.
The class implementing IContentsView3 must be registered in the 'Esri Contents Views' component category. You can see an example of this with the TOC Layer Filter Sample.
They can no longer be dynamically added or turned on/off with the visibility property.

As part of the transition from 9.x to 10, we were encouraging developers to move their TOC customization to dockable windows.
0 Kudos
CarlTremblay
New Contributor
Thank you verry much ...
0 Kudos