Dockable window in Arcmap 10

2836
7
03-16-2012 01:26 AM
MuhammetCiftci
New Contributor II
Hi,

I use a dockable window in Arcmap 10 in which I display a Windows Form. My question is : is it possible to remove the icon of the Form in taskbar ? I don't have this problem in Arcmap 9.

Thanks !
0 Kudos
7 Replies
MuhammetCiftci
New Contributor II
I found a solution : have to use the ShowInTaskbar property of Windows Form. Not needed in Arcmap 9.
0 Kudos
JimIsbell
New Contributor II
Would you mind posting your code to get a windows form displayed in a dockable window? I've been trying to get that to work and cannot seem to figure it out. Thanks!
0 Kudos
MuhammetCiftci
New Contributor II
First, you have to implement IDockableWindowDef Interface :

    [Guid("74036c8c-fa64-41fa-bfcf-d261e24b641f")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("MyDock")]
    public class MyDock : IDockableWindowDef
    {
[INDENT]private static IApplication m_application;

        public static IApplication application
        {
           
[/INDENT]
[INDENT=2]get
            {
               
[/INDENT]
[INDENT=3]return m_application;[/INDENT]
[INDENT=2]            }[/INDENT]
[INDENT]        }

        #region COM Registration Function(s)
        [ComRegisterFunction()]
        [ComVisible(false)]
        static void RegisterFunction(Type registerType)
        {
           
[/INDENT]
[INDENT=2]// Required for ArcGIS Component Category Registrar support
            ArcGISCategoryRegistration(registerType);
[/INDENT]
[INDENT]        }

        [ComUnregisterFunction()]
        [ComVisible(false)]
        static void UnregisterFunction(Type registerType)
        {
           
[/INDENT]
[INDENT=2]// Required for ArcGIS Component Category Registrar support
            ArcGISCategoryUnregistration(registerType);

            //
            // TODO: Add any COM unregistration code here
            //
[/INDENT]
[INDENT]        }

       
[/INDENT]
[INDENT]#region ArcGIS Component Category Registrar generated code
        private static void ArcGISCategoryRegistration(Type registerType)
        {
[/INDENT]
[INDENT=2]string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxDockableWindows.Register(regKey);
[/INDENT]
[INDENT]        }

        private static void ArcGISCategoryUnregistration(Type registerType)
        {
           
[/INDENT]
[INDENT=2]string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
            MxDockableWindows.Unregister(regKey);
[/INDENT]
[INDENT]}

        #endregion
[/INDENT]
[INDENT]        #endregion

        public RCPManagerDock()
        {
        }

        #region IDockableWindowDef Members

        string IDockableWindowDef.Caption
        {
           
[/INDENT]
[INDENT=2]get
            {
               
[/INDENT]
[INDENT=3]return "My Dock";[/INDENT]
[INDENT=2]            }[/INDENT]
[INDENT]        }

        int IDockableWindowDef.ChildHWND
        {
           
[/INDENT]
[INDENT=2]get
{
[/INDENT]
[INDENT=3]return myForm.Handle.ToInt32(); //You give your form's handle to the dock here[/INDENT]
[INDENT=2] }[/INDENT]
[INDENT]        }

        string IDockableWindowDef.Name
        {
           
[/INDENT]
[INDENT=2]get
            {
               
[/INDENT]
[INDENT=3]return myForm.Name;[/INDENT]
[INDENT=2]            }[/INDENT]
[INDENT]        }

        void IDockableWindowDef.OnCreate(object hook)
        {
           
[/INDENT]
[INDENT=2]m_application = hook as IApplication;[/INDENT]
[INDENT]        }

        void IDockableWindowDef.OnDestroy()
        {
        }

        object IDockableWindowDef.UserData
        {
           
[/INDENT]
[INDENT=2]get { return null; }[/INDENT]
[INDENT]        }

        #endregion
[/INDENT]
    }
0 Kudos
MuhammetCiftci
New Contributor II
Then, you have to create a button to open/close your dockable window :

[Guid("a048cbf6-e22b-4fa1-a803-b044d66e1b3e")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("DockCommand")]
public sealed class DockCommand : BaseCommand
{
[INDENT]private static IApplication m_application;
private static IDockableWindow m_dockableWindow;
private const string DockableWindowGuid = "{74036c8c-fa64-41fa-bfcf-d261e24b641f}";


#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
[/INDENT]
[INDENT=2]// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType);
[/INDENT]
[INDENT]}

[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
[/INDENT]
[INDENT=2]// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType);
[/INDENT]
[INDENT]}

#region ArcGIS Component Category Registrar generated code
private static void ArcGISCategoryRegistration(Type registerType)
{
[/INDENT]
[INDENT=2]string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Register(regKey);
[/INDENT]
[INDENT]}

private static void ArcGISCategoryUnregistration(Type registerType)
{
[/INDENT]
[INDENT=2]string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Unregister(regKey);
[/INDENT]
[INDENT]}

#endregion
#endregion

public DockCommand()
{
[/INDENT]
[INDENT=2]base.m_enabled = true;
base.m_category = "bla bla"; //localizable text
base.m_caption = "bla bla bla"; //localizable text
base.m_message = "bla bla"; //localizable text
base.m_toolTip = "bla bla bla"; //localizable text
base.m_name = "bla bla bla"; //unique id, non-localizable (e.g. "MyCategory_ArcMapCommand")
[/INDENT]
[INDENT=2]
try
{
[/INDENT]
[INDENT=3]string bitmapResourceName = GetType().Name + ".bmp";
base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
[/INDENT]
[INDENT=2]}
catch (Exception ex)
{
[/INDENT]
[INDENT=3]System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");[/INDENT]
[INDENT=2]}[/INDENT]
[INDENT]}


#region Overriden Class Methods

public override void OnCreate(object hook)
{
[/INDENT]
[INDENT=2]if (hook != null)
[/INDENT]
[INDENT=3]m_application = hook as IApplication;[/INDENT]
[INDENT]}


public override void OnClick()
{
[/INDENT]
[INDENT=2]if (m_application == null)
[/INDENT]
[INDENT=3]base.m_enabled = false;[/INDENT]
[INDENT=2]
LaunchDock();
[/INDENT]
[INDENT]}

public override bool Checked
{
[/INDENT]
[INDENT=2]get
{
[/INDENT]
[INDENT=3]return m_dockableWindow != null && m_dockableWindow.IsVisible();[/INDENT]
[INDENT=2]}[/INDENT]
[INDENT]}

#endregion

//Initialize the dockable window
private static void SetupDockableWindow()
{
[/INDENT]
[INDENT=2]if (m_dockableWindow == null)
{
[/INDENT]
[INDENT=3]IDockableWindowManager dockWindowManager = m_application as IDockableWindowManager;
if (dockWindowManager != null)
{
[/INDENT]
[INDENT=4]UID windowID = new UIDClass();
windowID.Value = DockableWindowGuid;
m_dockableWindow = dockWindowManager.GetDockableWindow(windowID);
[/INDENT]
[INDENT=3]}[/INDENT]
[INDENT=2]}[/INDENT]
[INDENT]}

public static bool LaunchDock()
{
[/INDENT]
[INDENT=2]if(!this.Checked)
{
[/INDENT]
[INDENT=3]if (m_dockableWindow == null)
{
[/INDENT]
[INDENT=4]//start the form here : Form myForm = new MyForm();
//myForm.Show();
SetupDockableWindow();
m_dockableWindow.Show(true);
[/INDENT]
[INDENT=3]}
else
{
[/INDENT]
[INDENT=4]m_dockableWindow.Show(true);[/INDENT]
[INDENT=3]}[/INDENT]
[INDENT=2]}
else
{
[/INDENT]
[INDENT=3]m_dockableWindow.Show(false);[/INDENT]
[INDENT=2]}[/INDENT]
[INDENT]}[/INDENT]
}
0 Kudos
JimIsbell
New Contributor II
Wow, looks a tad complicated but I'll see if I can work through it (I'm an intermediate-level programmer, but some of these concepts, like the "hook", are new to me). Thanks a lot for posting this; MUCH APPRECIATED!!!
-Jim
0 Kudos
MuhammetCiftci
New Contributor II
Most of the code is generated automatically when you create a button and a dockable window in visual studio.
0 Kudos
imranmd
New Contributor
Deat momobjk

"Can you please submit the complete project here/ send me an email "i.md63@yahoo.com

Thanks for your valuable time and considerations


,Regards
Imran
0 Kudos