Friday, January 23, 2015

Parenting Win-form and WPF form in ArcMap

Parenting of Win-form windows and WPF windows within a ArcMap application using C#.Net code snippets-

Step 1: Create a ArcMapWrapper.cs, wrapper class

        using System;
        using System.Windows.Forms;
        using ESRI.ArcGIS.Framework;

        namespace ArcMapClassLibrary2
        {
               class ArcMapWrapper:IWin32Window
               {
                    private IApplication _arcMapApplication;

                    public ArcMapWrapper( IApplication mApplication)
                    {
                       _arcMapApplication = mApplication;
                    }

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

Step 2: Access from Win-form

              WinForm fm = new WinForm();                        
              ArcMapWrapper wrapper= new ArcMapWrapper(map_application);  
              fm.ShowInTaskbar = false;        
              fm.Show(wrapper);

              //Try, it behaves like a modal dialog
              //fm.ShowDialog()

Step 3: Access from WPF Window

            WpfForm ws = new WpfForm();
            ArcMapWrapper wrapper = new ArcMapWrapper(m_application);

            var helper = new WindowInteropHelper(ws);
            helper.Owner = wrapper.Handle;
            ws.ShowInTaskbar = false;
            ws.Show();

           //Try, it behaves like a modal dialog      
           //ws. ShowDialog()
             
References:


ArcMap , arcobject , C#

0 comments :

Post a Comment

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me