Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Into my object inspector fever, I noticed that the default Object Inspector object does not dock anymore.

I only have a TabPage control and two tabs, one of those hosting the default inspector. (check black marks)

The other tabs works fine.

Also, this is the code I'm using for the Inspect() method:

    public void Inspect(IEnumRow objects, IEditor Editor)
        SetParent(_Inspector.HWND, DefaultPanelHandle);
        ShowWindow(_Inspector.HWND, SW_SHOW);
        _Inspector.Inspect(objects, Editor);

Why the default does not dock anymore? Any workarounds?

alt text

share|improve this question
up vote 3 down vote accepted

You can create a wrapper control which essentialy houses the ESRI's object inspector window and assures that any resizes are also reflected in the default inspector:

public class WindowContainerControl : Control
    private readonly IntPtr _childHandle;

    [DllImport("user32.dll", SetLastError = true)]
    private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

    private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    [DllImport("user32.dll", SetLastError = true)]
    private static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool repaint);

    private const int SW_SHOW = 5;

    public WindowContainerControl(IntPtr childHandle)
        _childHandle = childHandle;

    protected override void OnHandleCreated(EventArgs e)
        SetParent(_childHandle, Handle);
        ShowWindow(_childHandle, SW_SHOW);

    protected override void OnResize(EventArgs e)
        if (IsHandleCreated)
            MoveWindow(_childHandle, 0, 0, ClientSize.Width, ClientSize.Height, true);

Then, when you create the window for your custom object inspector (I assume it's an UserControl), you add this container in it and associate it with the ESRI's inspector handle. See below.

Here I assume the DefaultPanel is a Panel control in your tab page. Due to some weirdness you cannot place the container control directly to a tab page but you need to use an intermediate panel. Your scenario may be different, but I initialize the controls only when my implementation of IObjectInspector.HWND is first called:

// the container will reparent and house the default inspector
var windowContainer = new WindowContainerControl(_Inspector.HWND);

// when the size of the parent changes, the container's size changes
// as well, in turn the housed inspector window is also resized
windowContainer.Dock = DockStyle.Fill;

// The control containing the tabcontrol and it's pages.
// One of the pages has the panel in it (docked as well), exposed
// as the DefaultPanel property or field.
_myInspectorUserControl = new MyInspectorUserControl();

// Add the container in the custom inspector's designated panel

// return the _myInspectorUserControl hwnd

You may not go for this exact solution (just tested to work in ArcMap 9.3.1), but you get the gist - you basically need to resize the inner default inspector whenever the parent's size changes. The WindowContainerControl class merely does the dirty work of altering its child's size to fill its client area. Thus you only need to dock the WindowContainerControl instance, it takes care of the rest.

share|improve this answer
Hello petr! Your assumptions are correct, it is a UserControl and a Panel control. Thanks for your answer! I'll try this out and see if it works. Just for answering you deserve the points, as no one else would. :D – George Dec 13 '10 at 15:42

Your Answer


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.