LVectorStock::LVectorStock

#include "ltwrappr.h"

L_VOID LVectorStock::LVectorStock(pStock = NULL)

L_VOID LVectorStock::LVectorStock(pObject, pVector =NULL)

pVECTORSTOCK pStock;

/* pointer to a VECTORSTOCK structure */

pVECTOROBJECT pObject;

/* pointer to a VECTOROBJECT structure */

LVectorBase *pVector;

/* pointer to an LVectorBase object */

Constructs and initializes the different member variables of the LVectorStock object.

Parameter

Description

pStock

Pointer to a VECTORSTOCK structure that contains information used to create and initialize the new vector stock object.

pObject

Pointer to a VECTOROBJECT structure that contains information used to create and initialize the new vector stock object.

pVector

Pointer to an LVectorBase object with which the newly constructed vector stock object will be associated.

Returns

None

Comments

LVectorStock::LVectorStock(pStock) is a constructor for the LVectorStock object. It takes a valid pVECTORSTOCKpointer and creates an LVectorStock object.

LVectorStock::LVectorStock(pObject, pVector=NULL) creates an LVectorStock object based on the information provided in pObject and associates the newly created LVectorStock object with the specified LVectorBase object. This constructor can be used with the LVectorLayer::EnumObjects function, which returns a valid pVECTOROBJECT pointer in the LVectorLayer::EnumObjectsCallBack member function. It can also be used with LVectorBase::VectorEventProcCallBack, which can also return a pObject.

Note that it is possible to construct an invalid LVectorStock object using the LVectorStock::LVectorStock(pObject, pVector=NULL) constructor. For example:

   //pObject->nType == type other than VECTOR_STOCK
   //LVectorBase *pVector is valid
   LVectorStock MyVectorStock(pObject, pVectorBase);
   if (MyVectorStock.IsTypeValid() == FALSE)
      MessageBox(NULL, TEXT("Invalid Vector Object"), TEXT(""), MB_OK);

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:

LVectorStock::~LVectorStock, Class Members

Example

This is an example for LVectorStock::LVectorStock(pStock):

This example will add all of the stock objects from VecOfice.dll to the Active Layer of an LVectorBase object.

For an example for LVectorStock::LVectorStock(pObject, pVector=NULL), refer to LVectorArc::LVectorArc(pObject, pVector = NULL).

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
#define VECOFICE_OBJECT_COUNT 10
L_INT LVectorStock__LVectorStockExample(HWND hWnd, LVectorBase *pVector)
{
   L_INT          nRet;
   VECTORSTOCK    Stock;
   L_INT          iWidth = 10;
   UNREFERENCED_PARAMETER(hWnd);
   memset( &Stock, 0, sizeof(Stock));
   // Load the VECOFICE library.
   Stock.hInstDLL = LoadLibrary(MAKE_IMAGE_PATH(TEXT("VecOfice.dll")));
   // Tell the toolkit to load the stock object using the hInstDLL member.
   Stock.pszDLLName = NULL;
   // Fill in default pen, brush
   Stock.Pen.bExtPen = FALSE;
   Stock.Pen.nSize = sizeof( VECTORPEN );
   Stock.Pen.NewPen.LogPen.lopnStyle = PS_SOLID;
   Stock.Pen.NewPen.LogPen.lopnWidth.x = 1;
   Stock.Pen.NewPen.LogPen.lopnWidth.y = 1;
   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;
   LVectorLayer VectorLayer;
   nRet = pVector->GetActiveLayer(&VectorLayer);
   if (nRet == SUCCESS)
   {
      Stock.Point[0].z = Stock.Point[1].z = 0;
      for( Stock.nId = 0; Stock.nId <= VECOFICE_OBJECT_COUNT; Stock.nId++ )
      {         
         Stock.Point[ 1 ].x = Stock.Point[ 0 ].x + iWidth;
         Stock.Point[ 1 ].y = Stock.Point[ 0 ].y + iWidth;
         
         // 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 ); 
         LVectorStock VectorStock(&Stock);
         nRet = VectorLayer.AddObject(&VectorStock);
         if(nRet != SUCCESS)
            return nRet;
         Stock.Point[ 0 ].x += iWidth;
         if( Stock.Point[ 0 ].x > 11 * iWidth )
         {
            Stock.Point[ 0 ].x = 0;
            Stock.Point[ 0 ].y += iWidth;
         }
      }
      
      nRet = pVector->SetParallelogram(NULL, NULL);
      if(nRet != SUCCESS)
         return nRet;
      nRet = pVector->SetOrigin(NULL);
      if(nRet != SUCCESS)
         return nRet;
      nRet = pVector->SetCamera(NULL);
      if(nRet != SUCCESS)
         return nRet;
   }
   else
   {
      MessageBox(NULL, TEXT("No Active Layer--Load a vector and run again"), TEXT(""), MB_OK);
      return nRet;
   }
   //LVectorStock destructor called when VectorStock goes out of scope
   return SUCCESS;
}