Modifying VPE Objects in a Template

<< Click to Display Table of Contents >>

Navigation:  dycodoc Template Processing > VPE Object Processing >

Modifying VPE Objects in a Template

Previous pageReturn to chapter overviewNext page

VPE Objects in a template are addressed by their names.

NOTE: Do not mismatch names of VPE objects with names of fields. VPE Objects are the graphical objects like lines, text and pictures. You can assign a unique name to each object in dycodoc by using the object's "properties" dialog or in the "Pages & Layers" treeview. In contrast, fields are the variables of DataSources that can be filled with values.

In the dycodoc file "sample2.dcd", the object named "Text1" contains the field $(GoodByePhrase). With the following code sample we will retrieve this object and set its BkgMode to solid and paint it in red color. The object is modified within the template.

Sample Code for the VPE Control

// Declare an object variable for a VPE object:

Dim obj as TVPEObject

 

Dim tpl as TVPETemplate

VPE.OpenDoc

tpl = VPE.LoadTemplate("\dycodoc\samples\sample2.tpl")

SetFields(tpl)   // this procedure had been declared in the very first sample

 

// Retrieve the object named "Text1" from the template:

obj = tpl.FindVpeObject("Text1")

 

// Change its properties:

obj.BkgMode = VBKG_SOLID

obj.BkgColor = COLOR_RED

 

// Dump the template and show the preview:

VPE.DumpTemplate(tpl)

VPE.Preview

 

 

Sample Code for the VPE DLL (C/C++)

// Declare an object variable for a VPE object:

VpeHandle hObj;

 

VpeHandle hTpl;

VpeHandle hDoc = VpeOpenDoc(hWnd, "Sample", 0);

hTpl = VpeLoadTemplate(hDoc, "\\dycodoc\\samples\\Sample2.tpl");

if (hTpl == NULL)

 return;         // an error had occurred, e.g. the file was not found

SetFields(hTpl);  // this procedure had been declared in the very first sample

 

 

// Retrieve the object named "Text1" from the template:

hObj = VpeFindTplVpeObject(hTpl, "Text1")

if (hObj)

{

  // The object is present, change its properties:

 VpeSetBgkMode(hObj, VBKG_SOLID);

 VpeSetBkgColor(hObj, COLOR_RED);

}

 

// Dump the template and show the preview:

VpeDumpTemplate(hDoc, hTpl);

VpePreviewDoc(hDoc, NULL, VPE_SHOW_NORMAL);