OriginObject::ConnectTo

Description

Connect one object to another object

Syntax

BOOL ConnectTo( OriginObject & objTarget, int nTargetReferencePoint = -1, int nReferencePoint = -1, BOOL bVisibleConnector = TRUE, DWORD dwRigid = OCR_SITE1 | OCR_SITE2, RECT * lpConfineRect = NULL )

Parameters

objTarget
[input] the object want to connect to
nTargetReferencePoint
[input] reference point on target object. Value is from CONNECTORTETHERINGPOINT enum.
nReferencePoint
[input] reference point on object being connected. Value is from CONNECTORTETHERINGPOINT enum.
bVisibleConnector
[input] if TRUE connector is visible.
dwRigid
[input] connector rigidity. Combination of OCR_SITE1 and OCR_SITE2 bits. If OCR_SITE1 is set, objTarget will follow this object when this object is moved. If OCR_SITE2 is set, this object will follow objTarget, when objTarget is moved.
lpConfineRect
[input] confinement rectangle to restrict movement of connected object if corresponding connection is not rigid. If lpConfineRect is NULL, no confinement is applied. If not NULL then following logic is followed: assume object1 is connected to object2 and connection on the object1 site is not rigid. Object1 will be restricted in movement up, down, left or right such that distance to the object2 is less than (lpConfineRect->top * object2.Height / 1000.0), (lpConfineRect->bottom * object2.Height / 1000.0), (lpConfineRect->left * object2.Width / 1000.0) and (lpConfineRect->right * object2.Width / 1000.0) respectively.

Return

TRUE if successful, FALSE otherwise

Examples

EX1

// this example will show how to connect graph object to another graph object. 
// If move Line object Text and Rect will be moved together
void OriginObject_ConnectTo_Ex1()
{
    GraphPage gp;
    gp.Create();
    GraphLayer gl = gp.Layers();
    
    GraphObject goLine = gl.CreateGraphObject(GROT_LINE);
    GraphObject goText = gl.CreateGraphObject(GROT_TEXT);
    GraphObject goRect = gl.CreateGraphObject(GROT_RECT);
    goText.Text = "Hello";
    goText.ConnectTo(goLine);
    goRect.ConnectTo(goLine);
}

EX2

//Run this code after OriginObject_ConnectTo_Ex1 to see the result.
void OriginObject_ConnectTo_Ex2()
{
        GraphLayer gl = Project.ActiveLayer();
        if ( gl )
        {
                GraphObject goRect = gl.GraphObjects("Rect");
                if ( goRect )
                        goRect.ConnectTo(NULL);//disconnect from other graph object.
        }
        return;
}

Remark

See Also

OriginObject::GetConnectedObjects

header to Include

origin.h