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) oform.Show() End Sub
Here is the ESRI form
Public Class window Public Sub New(ByVal hook As Object) InitializeComponent() Me.Hook = hook End Sub Private m_hook As Object Public Property Hook() As Object Get 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 m_windowUI.Dispose(Param) End If MyBase.Dispose(Param) 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) dockWindow.Show(True)
And still does not work.