Select to view content in your preferred language

Custom TOC layer problem on getting Mxdocument from Axmapcontrol

485
1
12-19-2011 08:07 PM
ilankumaranm
Emerging Contributor
i am adding a layers to axmapcontrol like  
axMapControl1.Map.AddLayer((ILayer)rasterLayer);

Now i need to use a custom Toc layer which is usercontrol.i hve added the custom toc usercntrl dll and trying to send the Imxdocument from the Axmapcontrol. How to initialize the m_application such a way axmapcontrol will be considered as m_application and to send the document.
//i tried this for getting the mxdocument from axmapcontol where app  is comming null.

public IMxDocument OnCreate(object hook)
        {
                           m_hookHelper = new HookHelperClass();
                m_hookHelper.Hook = hook;

            IApplication app = m_hookHelper.Hook as IApplication;
            IMxDocument appDocument = (IMxDocument)app.Document;
            return appDocument;
  }

//invoke usrcntrl library.
TOCLayerFilter tc = new TOCLayerFilter();
IMxDocument imx= (IMxDocument)m_application.Document;
tc.Activate(axMapControl1.hWnd, imx)



kindly help asap...
////
to tell my question more clearly ..
i have wpf app with axcontrol hosted and raster layer in axcontrol ..and need to add the custom toc as in the link..the custom code has a activate method which gets the mxdocument,how do i pass from axmapcontrol..i added this dll in my app. how to pass mxd doc values to activate method
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000026q000000
0 Kudos
1 Reply
NeilClemmons
Honored Contributor
If your application is not running inside of ArcMap then you can't have an IMxDocument reference or an IApplication reference.  IMxDocument refers to an ArcMap document and IApplication refers to the ArcMap application itself.  If you're not inside of ArcMap then neither of those things exist in your application.
0 Kudos