GraphLayer::Attach

Contents

Description

Attached a layer in an Origin graph window to the object based on the graph name and the layer index.

Syntax

BOOL Attach( LPCSTR lpcszWinName, int nLayerNum = -1 )

Parameters

lpcszWinName
[input] the name of an existing Origin graph window
nLayerNum
(optional) the 0-offset index of the layer in the graph window to attach
or <0 for the active layer.

Return

TRUE for success, otherwise FALSE.

Examples

EX1

// For this example to run, a graph window must exist in the project.
// Make sure that the window has at least two layers.
// Make layer 2 active before running the function.
void    GraphLayer_Attach_ex1()
{
    // Construct a GraphLayer object and attach it to the second layer of the current window.
    // (note that in the constructor the layer index is 0-offset, so the
    // first layer needs index 0)
    GraphLayer        gl(Project.GraphPages(0).GetName(), 1);
    
    // Display the index of the layer in graph page
    // (note that the index returned from the "GetIndex" method
    // is 1-offset, so the first layer will have index 1):
    out_int("Layer index = ", gl.GetIndex());
    
    // Now attach the first layer:
    gl.Attach(Project.GraphPages(0).GetName(), 0);

    // Display the index of the layer in graph page.
    // (note that the index returned from the "GetIndex" method
    // is 1-offset, so the first layer will have index 1):
    out_int("Layer index = ", gl.GetIndex());
}

Remark

See Also

header to Include

origin.h