This has been bugging me for a while. I can easily call a form from a button using ShowDialog() if I use standard vb.net windows form. However when I use the ESRI addin dockable window which uses hooks in the form I can't seem to open it.

It requires a 'hook as object' when I try to call it from a button. ESRI forms do not use the ShowDialog() method and require you to use Show(). I have searched and look everywhere but can't see how to call the form that uses hooks. Do I need to create a new hook object in the button class?

When I click the button nothing happens and it turns grey. The form is not hidden behind ArcMap or anything.

Here is what I use to call the form:

Protected Overrides Sub OnClick()
    Dim oform As New window(Me.Hook)

End Sub

Here is the ESRI form

Public Class window

Public Sub New(ByVal hook As Object)


    Me.Hook = hook
End Sub

Private m_hook As Object

Public Property Hook() As Object
  Return m_hook
End Get
Set(ByVal value As Object)
  m_hook = value
End Set
End Property

Public Class AddinImpl
Inherits ESRI.ArcGIS.Desktop.AddIns.DockableWindow

Private m_windowUI As window

Protected Overrides Function OnCreateChild() As System.IntPtr
  m_windowUI = New window(Me.Hook)
  Return m_windowUI.Handle
End Function

Protected Overrides Sub Dispose(ByVal Param As Boolean)
  If m_windowUI IsNot Nothing Then
  End If

End Sub

  End Class

End Class


Now I tried

Dim dockWindow As ESRI.ArcGIS.Framework.IDockableWindow

    Dim dockWinID As UID = New UIDClass()
    dockWinID.Value = My.ThisAddIn.IDs.window
    dockWindow = My.ArcMap.DockableWindowManager.GetDockableWindow(dockWinID)


And still does not work.

  • The hook is a reference to the application (e.g. ArcMap). But I think the idea is to use the IDockableWindowManager interface of the application object: call GetDockableWindow() and then Show() on the returned IDockableWindow instance. – Berend Jan 26 '16 at 12:23
  • Sorry, the hook should be ArcMap.Application, not ArcMap. – Berend Jan 26 '16 at 12:32
  • I tried the GetDockableWindow() method above and the button still does not work. – Daz Jan 26 '16 at 13:50
  • See my answer below, I just tried it, and can confirm that it works. – Berend Jan 26 '16 at 14:49
  • I am trying it from your answer using vb.net. If you see the new code I have written in the update above it does not work. Unless I am missing something. – Daz Jan 26 '16 at 14:58

Here's a complete sample that shows how to use the DockableWindowManager (C#, sorry):

var w = ArcMap.DockableWindowManager.GetDockableWindow(new UIDClass { Value = ThisAddIn.IDs.DockableWindow1 });
if (w != null)

In VB.Net, the ID's are in My.ThisAddIn.IDs.


I got it working. Seems I had to assign my dockwindow to Nothing before I use the getDockableWindow() method. Also had to change show() method.

Protected Overrides Sub OnClick()


        ' Only get/create the dockable window if it's not there

        Dim dockWindow As ESRI.ArcGIS.Framework.IDockableWindow

        dockWindow = Nothing

        If dockWindow Is Nothing Then
            Dim dockWinID As UID = New UIDClass()
            dockWinID.Value = My.ThisAddIn.IDs.window
            dockWindow = My.ArcMap.DockableWindowManager.GetDockableWindow(dockWinID)
        End If

        dockWindow.Show((Not dockWindow.IsVisible()))

    Catch ex As Exception

    End Try
End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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