The LEADTOOLS Vector SDK supports Stock objects libraries. These are Dynamic Link Libraries that contain user-defined objects.
The VECOFICE Library comes with more than 100 pre-defined object shapes for multiple purposes such as arrows, flowchart symbols, etc.
The following example adds all the objects in the VECOFICE library to the default layer of a vector handle:
#include "ltvkrn.h"
#include "vecofice.h"
void LoadVecOficeLibrary( pVECTORHANDLE pVector )
{
VECTORSTOCK Stock;
L_INT i;
L_DOUBLE X, Y;
const L_DOUBLE SIZE = 2.0;
// Initiate a new VECTOR_STOCK object.
L_VecInitObject( &Stock.Object );
Stock.Object.nType = VECTOR_STOCK;
Stock.Object.nSize = sizeof( VECTORSTOCK );
// Load the VECOFICE library.
Stock.hInstDLL = LoadLibrary(TEXT("VecOfice.dll"));
// Tell the toolkit to load the stock object using the hInstDLL member.
Stock.pszDLLName = NULL;
// Fill in default pen, brush and font.
Stock.Pen.nSize = sizeof( VECTORPEN );
Stock.Pen.bExtPen = FALSE;
Stock.Pen.NewPen.LogPen.lopnStyle = PS_SOLID;
Stock.Pen.NewPen.LogPen.lopnWidth.x = 1;
Stock.Pen.NewPen.LogPen.lopnWidth.y = 0;
Stock.Pen.NewPen.LogPen.lopnColor = RGB( 0xFF, 0x00, 0x00 );
Stock.Brush.VectorBrushStyle = VECTORBRUSH_STANDARD;
Stock.Brush.nSize = sizeof( VECTORBRUSH );
Stock.Brush.BrushType.StandardBrush.LogBrush.lbStyle = PS_SOLID;
Stock.Brush.BrushType.StandardBrush.LogBrush.lbHatch = 0;
Stock.Brush.BrushType.StandardBrush.LogBrush.lbColor = RGB( 0x00, 0xFF, 0x00 );
X = 0.0;
Y = 0.0;
// Add all objects, use a grid of 10 horizontal objects
for( i = 0; i < VECOFICE_OBJECT_COUNT; i++ )
{
// Set object ID.
Stock.nId = i;
Stock.Point[ 0 ].x = X;
Stock.Point[ 0 ].y = Y;
Stock.Point[ 0 ].z = 0.0;
Stock.Point[ 1 ].x = X + SIZE;
Stock.Point[ 1 ].y = Y + SIZE;
Stock.Point[ 1 ].z = 0.0;
// We want to have random colors for each object.
Stock.Pen.NewPen.LogPen.lopnColor = RGB( rand() % 256, rand() % 256, rand() % 256 );
Stock.Brush.BrushType.StandardBrush.LogBrush.lbColor = RGB( rand() % 256, rand() % 256, rand() % 256 );
// Add the object to the default layer.
L_VecAddObject( pVector, NULL, VECTOR_STOCK, &Stock, NULL );
// Update position for next object.
if( !( ( i + 1 ) % 10 ) )
{
Y -= SIZE * 3.0 / 2.0;
X = 0.0;
}
else
{
X += SIZE * 3.0 / 2.0;
}
}
}