Mapx添加永久图层

    CMapXLayerInfo LayerInfo ;

    CMapXFields MapFields ;
    
    
try {

        LayerInfo.CreateDispatch( LayerInfo.GetClsid() ) ;
        MapFields.CreateDispatch( MapFields.GetClsid() );

        MapFields.AddIntegerField( 
" C_ID "  , TRUE ) ;
        MapFields.AddStringField( 
" Name "  ,  32  ) ;

        COleVariant vFields;
        vFields.vt 
=  VT_DISPATCH ;
        vFields.pdispVal 
=  MapFields;
        vFields.pdispVal
-> AddRef();

        LayerInfo.SetType( miLayerInfoTypeNewTable );  
// 如果是miLayerInfoTypeTemp,则为临时图层
        LayerInfo.AddParameter( " Filespec "  , COleVariant( " peirenlei " ) );
        LayerInfo.AddParameter(
" Name "  , COleVariant( " peirenlei " )  );
        LayerInfo.AddParameter(
" Fields " , vFields );

        m_ctrlMapX.GetLayers().Add( LayerInfo );
        
    }
    
catch (COleDispatchException *  e) {
        e
-> ReportError();
        e
-> Delete();
    } 
catch (COleException *  e) {
        e
-> ReportError();
        e
-> Delete();
    }    
 

你可能感兴趣的:(MapX)