Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

"New Map File" analog

$
0
0
I have a simple code to create new document in ArcMap and add one layer from file (.lyr). Code runs on a click of add-in button.
If I run this code, ArcMap always shows "Do you want to save..?" dialog.

Here is the code:
Code:

    public class TestNewDoc : ESRI.ArcGIS.Desktop.AddIns.Button
    {
        protected override void OnClick()
        {
            ArcMap.Application.OpenDocument("Normal.mxt");

            IGxLayer gxLayer = new GxLayerClass();
            IGxFile gxFile = (IGxFile)gxLayer;
            gxFile.Path = "C:\\temp\\layer.lyr";

            ArcMap.Document.AddLayer(gxLayer.Layer);
        }
    }

In fact, I want to have a code, which acts the same as "New Map File" ArcMap command.
Any ideas?

Viewing all articles
Browse latest Browse all 1374

Trending Articles