[GIS] Creating floating-only (non-dockable) window in ArcMap using ArcObjects

arcmaparcobjectsc

I'm looking for a way to create a floating window in ArcMap. To give an example just look at the window of the Identify tool.

Floating means that it stays in front of the map document at all times and that the user can continue to work with ArcMap. I know that the interface IDockableWindowDef can be used to create dockable windows which can also float, but I don't want them to dock. To my knowledge it's not possible to prevent forms created by IDockableWindowManager from docking if e.g. the user pushes them to the border of the ArcMap window.

Any ideas?


The solution was to search for keywords like child window and MDI. HTH

The problem's solution seems to be as easy as @llcf's answer:

MyForm form = new MyForm();
form.Show(NativeWindow.FromHandle(new IntPtr(m_application.hWnd)));

Best Answer

If in .net I think the examples I have seen uses a helper class as below:

var form = new Form1();
form.Show(new WindowWrapper(_mxDocument.ActiveView.ScreenDisplay.hWnd));

public class WindowWrapper : System.Windows.Forms.IWin32Window
  {
    public WindowWrapper(IntPtr handle)
    {
      m_hwnd = handle;
    }
    public WindowWrapper(int handle)
    {
      m_hwnd = (IntPtr)handle;
    }
    public IntPtr Handle
    {
      get
      {
        return m_hwnd;
      }
    }
    private IntPtr m_hwnd;
  }
Related Question