LVectorObject::UnlockObject
#include "ltwrappr.h"
virtual L_INT LVectorObject::UnlockObject(pObject)
pVECTOROBJECT pObject; |
/* pointer to a vector object */ |
Sets the object information of the class object. This function is available in the LEADTOOLS Vector Imaging Pro Toolkit.
Parameter |
Description |
pObject |
Pointer to a VECTOROBJECT structure that contains the vector object information to set. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function is used to update the object information of the class object.
To use this method, declare a variable of type VECTOROBJECT and pass the address to the LVectorObject::LockObject() method. After modifying the vector object settings, call LVectorObject::UnlockObject(). LVectorObject::LockObject() and LVectorObject::UnlockObject() should always be called in pairs. A more useful form of this method is available in any of the LVectorObject derived classes.
Before an object has been added to the LVectorBase object, using LVectorBase::AddObject or LVectorLayer::AddObject, UnlockObject() can be used to change ALL properties of an object. However, once the object has been added to the LVectorBase object, some properties cannot be changed using LVectorObject::UnlockObject(). Specifically, nPointCount, *Point, pszText, and pbyType cannot be changed. However, as long as the number of points does not change, the coordinates of the individual points can always be modified using LVectorObject::UnlockObject().
To get the current object information for a class object, call LVectorObject::LockObject.
LVectorObject::LockObject and LVectorObject::UnlockObject must be called in pairs.
Required DLLs and Libraries
LVKRN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
|
Topics: |
Example
// This example will add a new green polyline to the Active Layer LVectorBase object.
L_VOID Example79(HWND hWnd, LVectorBase *pVector)
{
VECTORPOLYLINE PolyLine;
LVectorPolyLine VectorPolyLine;
VectorPolyLine.LockObject(&PolyLine);
//Change default properties
PolyLine.nPointCount = 4;
VECTORPOINT Points[4] = {
50, 50, 0, 0,
80, 50, 0, 0,
80, 80, 0, 0,
50, 80, 0, 0
};
PolyLine.Point = Points;
PolyLine.Pen.bExtPen = FALSE;
PolyLine.Pen.NewPen.LogPen.lopnColor = RGB(0,255,0);
VectorPolyLine.UnlockObject(&PolyLine);
pVector->AddObject(&VectorPolyLine );
}
// This example will add a rectangle to the Active Layer LVectorBase object.
// Once added, the rectangle will be rotated twice.
// Rotating the first time 90 degrees, the object type stays as VECTOR_RECTANGLE.
// Rotating the second time 45 degrees, the object type changes to a VECTOR_POLYDRAW.
L_VOID Example107(HWND hWnd, LVectorBase *pVector)
{
VECTORRECTANGLE Rectangle;
L_INT nRet;
L_TCHAR *pszType;
//Create Rectangle Object
Rectangle.Point[0].x = 30;
Rectangle.Point[0].y = 30;
Rectangle.Point[0].z = 10;
Rectangle.Point[1].x = 80;
Rectangle.Point[1].y = 50;
Rectangle.Point[1].z = 10;
Rectangle.Brush.nSize = sizeof(VECTORBRUSH);
Rectangle.Brush.VectorBrushStyle = VECTORBRUSH_STANDARD;
Rectangle.Brush.BrushType.StandardBrush.LogBrush.lbColor = RGB(0,128,0);
Rectangle.Brush.BrushType.StandardBrush.LogBrush.lbStyle = BS_SOLID;
Rectangle.Pen.nSize = sizeof( VECTORPEN );
Rectangle.Pen.bExtPen = FALSE;
Rectangle.Pen.NewPen.LogPen.lopnStyle = PS_SOLID;
Rectangle.Pen.NewPen.LogPen.lopnWidth.x = 2;
Rectangle.Pen.NewPen.LogPen.lopnWidth.y = 2;
Rectangle.Pen.NewPen.LogPen.lopnColor = RGB(255,0,0);
LVectorRectangle VectorRectangle(&Rectangle);
pVector->AddObject(&VectorRectangle);
//Rotate 90 degrees along the Z-Axis--it stays a VECTOR_RECTANGLE
MessageBox(NULL, TEXT("Rotating 90 degrees along the Z-axis"), TEXT(""), MB_OK);
VECTORPOINT pointRotation;
pointRotation.x = 0;
pointRotation.y = 0;
pointRotation.z = 90;
VECTORRECTANGLE RectangleTemp;
nRet = VectorRectangle.LockObject(&RectangleTemp);
if (nRet == SUCCESS)
{
RectangleTemp.Pen.NewPen.LogPen.lopnColor = RGB(0,0,255);
VectorRectangle.UnlockObject(&RectangleTemp);
}
//Rotate rectangle 45 degrees--it becomes an VECTOR_POLYDRAW object
pointRotation.x = 0;
pointRotation.y = 0;
pointRotation.z = 45;
VectorRectangle.SetRotation(&pointRotation);
//Cannot call LockObject/UnlockObject here, but can still change properties
//Object type is still a Rectangle
pszType = VectorRectangle.IsTypeValid() ?
TEXT("Valid Type--can call LockObject()/UnlockObject() and SetObjectAttributes() to change object properties") :
TEXT("Invalid Type--can call SetObjectAttributes() to change object properties");
MessageBox(NULL, pszType, TEXT(""), MB_OK);
//Change color with SetObjectAttributes()
VECTORBRUSH brush;
brush.VectorBrushStyle = VECTORBRUSH_STANDARD;
brush.BrushType.StandardBrush.LogBrush.lbColor = RGB(128,128,0);
}