DataRange::Destroy

Description

Destroy this Origin object.

Syntax

BOOL Destroy( DWORD dwCntrl = 0 )

Parameters

dwCntrl

Return

TRUE if successful.

Examples

EX1

// helper function for example DataRange_Destroy_Ex1
#include <Range.h>
void refresh(int nWinType)
{
    if(nWinType == EXIST_WKS)
    {    
        Worksheet wks = Project.ActiveLayer();
        wks.GetPage().Refresh();
    }
}

void DataRange_Destroy_Ex1()
{    
    // This example assumes you have a worksheet with xy data, 
    // and have made selected xy ranges.
    int nWinType;
    // This bracket defines a scope for dr
    {    
        // Get dr from Project. 
        // dr contains a reference to Projects selection.
        DataRange dr;
        nWinType = Project.GetSelection(dr);                                            
    }
    // dr is out of scope and has been destroyed by the destructor, 
    // but the range in the Project is not destroyed.
 
    // Refresh wks page. 
    refresh(nWinType);
 
    // This bracket defines a scope for dr
    {    
        // Get dr from Project. 
        // dr contains a reference to Projects selection. 
        // To destroy the datarange, call Destroy()
        DataRange dr;
        nWinType = Project.GetSelection(dr);
 
        // Now explicitly destroy dr. 
        dr.Destroy();
        if(!dr)
                out_str("dr was destroyed!");
    }
 
}

Remark

Destroys the DataRange object, as well as the range associated with a Project, if the DataRange object is associated with a Project.

It is not necessary to call Destroy() to destroy the DataRange object itself, since the destructor for DataRange will be called when the object goes out of scope.

However, if the DataRange object is associated with a range in a Project, then the destructor of the DataRange object will not delete the range in the Project.

To delete the range in a Project, call Delete() explicitly.

See Also

DataRange::Create

header to Include

origin.h