1

I have a windows form which opens with my ICommand, referenses IApplication and does some staff with it( it is not relevent ). The problem is that I want it to be onTop within ArcMap, and minimized if ArcMap is minimized. Two obvious solutions doesn't satisfy my requirements.

  1. Set form's Topmost = true. (Stays on top even if ArcMap is minimized.)
  2. Use DockedWindow. I have actually around dozen of such forms, I don't want to change all the projects structure due to such minor requirement.

Is there a way to make windows form be "adopted" by ArcMap window?

1 Answer 1

1

turns out there exists a solution online. Shortly, codes are like this.

add this class:

 public class ArcMapWindow : System.Windows.Forms.IWin32Window
 {
    private IApplication m_app;

    public ArcMapWindow(IApplication application)
    {
        m_app = application;
    }

    public System.IntPtr Handle {
        get { return new IntPtr(m_app.hWnd); }
    }

 }

and use like that:

form.Show(new ArcMapWindow(m_application));

provided by: https://dbouwman.wordpress.com/2007/09/05/parenting-forms-to-arcmap-the-easy-way/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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