Start with the project you created in Initializing and Loading a Vector Image
Take the following steps to create and initialize the automation objects:
#include "l_bitmap.h"
. Note that the path needs to match the path used when the toolkit was installed on your system.
#include "C:/LEADTOOLS23/Include/ltpnt.h"
#include "C:/LEADTOOLS23/Include/lttlb.h"
#include "C:/LEADTOOLS23/Include/ltcon.h"
#include "C:/LEADTOOLS23/Include/ltaut.h"
ResetView
function with the following code:
static L_VOID ResetView(HWND hWnd, pVECTORHANDLE pVector, pAUTOMATIONHANDLE pAutomation)
{
VECTORPOINT Scale;
VECTORPOINT Rotation;
VECTORPOINT Translation;
POINT pt;
L_AutSetUndoEnabled(pAutomation, FALSE);
Scale.x = Scale.y = Scale.z = 1.0;
L_VecSetScale(pVector, &Scale, NULL, NULL, 0L);
Rotation.x = Rotation.y = Rotation.z = 0.0;
L_VecSetRotation(pVector, &Rotation, NULL, NULL, 0L);
Translation.x = Translation.y = Translation.z = 0.0;
L_VecSetTranslation(pVector, &Translation, NULL, 0L);
pt.x = 0;
pt.y = 0;
L_VecSetPan(pVector, &pt);
L_VecSetParallelogram(pVector, NULL, NULL);
L_VecSetOrigin(pVector, NULL);
L_VecSetCamera(pVector, NULL);
L_AutSetUndoEnabled(pAutomation, TRUE);
InvalidateRect(hWnd, NULL, FALSE);
}
WndProc
function:
static L_INT EXT_CALLBACK ContainerCallback(pCONTAINERHANDLE pContainer, CONTAINEREVENTTYPE nEventType, L_VOID *pEventData, L_VOID *pUserData)
{
HWND hWnd;
pCONTAINEROBJECTDATA pObjectData;
switch (nEventType)
{
case CONTAINER_EVENT_TYPE_DRAW:
pObjectData = (pCONTAINEROBJECTDATA)pEventData;
if (pObjectData->fState == CONTAINER_STATE_END || pObjectData->fState == CONTAINER_STATE_ABORT)
{
L_ContainerGetOwner(pContainer, &hWnd);
InvalidateRect(hWnd, NULL, FALSE);
}
break;
}
return SUCCESS;
}
WndProc
function, right after the HDC hDC;
statement:
static pAUTOMATIONHANDLE pAutomation;
static pCONTAINERHANDLE pContainer;
static pTOOLBARHANDLE pToolbar;
CONTAINERMETRICS ContainerMetrics;
WM_CREATE
of WndProc
:
// create the automation handle
L_AutInit(&pAutomation);
L_AutCreate(pAutomation, AUTOMATION_MODE_VECTOR, 0L);
// create the toolbar
L_TBInit(&pToolbar);
L_TBCreate(pToolbar, hWnd, TEXT("Vector"), TOOLBAR_VECTOR);
L_TBSetVisible(pToolbar, TRUE);
// add it to the automation object
L_AutSetToolbar(pAutomation, pToolbar);
// create the container
L_ContainerInit(&pContainer);
L_ContainerCreate(pContainer, hWnd);
// set its callback
L_ContainerSetCallback(pContainer, ContainerCallback, NULL);
// add it to the automation object
L_AutAddContainer(pAutomation, pContainer, &Vector);
// set it as the active container
L_AutSetActiveContainer(pAutomation, pContainer);
ResetView
function call just before the return 0;
statement in WM_CREATE
to:
ResetView( hWnd, &Vector, pAutomation );
WM_SIZE
:
// set container limits to entire client area
ContainerMetrics.nSize = sizeof( CONTAINERMETRICS );
ContainerMetrics.dwMask = CMF_LIMITS;
CopyRect( &ContainerMetrics.rcLimits, &Rect );
L_ContainerSetMetrics ( pContainer, &ContainerMetrics );
WM_DESTROY
message, just before the call to L_VecFree:
// destroy container
L_AutRemoveContainer(pAutomation, pContainer);
L_ContainerFree(pContainer);
// destroy automation
L_AutFree(pAutomation);
// destroy toolbar
L_TBFree(pToolbar);
#pragma
comment lines. Note that the path needs to match the one that is on your system.
#if defined(FOR_WIN64)
#pragma comment(lib, "C:\\LEADTOOLS23\\Lib\\CDLL\\x64\\Lvaut_x.lib")
#pragma comment(lib, "C:\\LEADTOOLS23\\Lib\\CDLL\\x64\\Lvcon_x.lib")
#pragma comment(lib, "C:\\LEADTOOLS23\\Lib\\CDLL\\x64\\Lvtlb_x.lib")
#elif defined(FOR_WIN32)
#pragma comment(lib, "C:\\LEADTOOLS23\\Lib\\CDLL\\Win32\\Ltaut_u.lib")
#pragma comment(lib, "C:\\LEADTOOLS23\\Lib\\CDLL\\Win32\\Ltcon_u.lib")
#pragma comment(lib, "C:\\LEADTOOLS23\\Lib\\CDLL\\Win32\\Lttlb_u.lib")
#endif // #if defined(FOR_WIN64)