Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Kind of a newbie with ArcObjects .NET. Trying to open a dockable window with the following code:

public class CAD_Test_01_button : ESRI.ArcGIS.Desktop.AddIns.Button
{
    public CAD_Test_01_button()
    {
    }

    protected override void OnClick()
    {

        UID dockWinID = new UIDClass();
        dockWinID.Value = ThisAddIn.IDs.DockableWindow1;

        // Use GetDockableWindow directly as we want the client IDockableWindow not the internal class
        IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
        dockWindow.Show(true);

    }

    protected override void OnUpdate()
    {
    }
}

But I get the errors:

Error: The type or namespace name 'IDockableWindow' could not be found (are you missing a using directive or an assembly reference?)

Error: The name 'ArcMap' does not exist in the current context

What references could I be missing?

Thx,

Rich

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

The code below works for me:

using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.esriSystem;

namespace ArcMapAddin2
{
    public class MyButton1 : ESRI.ArcGIS.Desktop.AddIns.Button
    {
        private static IDockableWindow _DockWindow;
        public MyButton1()
        {
            UID dockWinID = new UIDClass();
            dockWinID.Value = @"Microsoft_ArcMapAddin2_MyDockwin";
            _DockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
        }

        protected override void OnClick()
        {
            _DockWindow.Show(!_DockWindow.IsVisible());
        }

        protected override void OnUpdate()
        {
        }
    }
}
share|improve this answer
add comment

IDockableWindow is in the ESRI.ArcGIS.Framework namespace - reference it and add a using statement.

ArcMap will not work except in VBA. You need to create your manager from the "hook" object in the OnCreate event.

IApplication m_app = hook as IApplication;
IDockableWindowManager pDocWinMgr = m_app as IDockableWindowManager;
share|improve this answer
    
ArcMap is a helper class that is included with ArcMap add-ins if you use the add-in template wizard. –  blah238 Aug 20 '11 at 6:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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