LAnnAutomation::InsertTextTokenTable

#include "ltwrappr.h"

virtual L_INT LAnnAutomation::InsertTextTokenTable(pTextToken)

pANNTEXTTOKEN pTextToken;

/* pointer to a structure that defines the text token */

Inserts a text token into the text token table.

Parameter

Description

pTextToken

Pointer to a structure that defines the text token table to insert.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The text token table is stored in the automation object.

This function inserts a token defined by pTextToken into the text token table. If the token already exists, the existing token is overwritten. If the token does not already exist, it is created.
The text token table can be displayed by performing the following steps:

1.

Right-click on a Button, Note, PushPin, Rubber Stamp, Stamp, Text, or Text Pointer annotation object.

2.

Select Text option in menu that appears.

3.

Click the Insert Token button. A menu for the existing text token table appears, as shown in the following figure:

image\TokenTable3.gif

4.

Select the token to be inserted.

Note that the text token table above contains a separator. To add a separator, set a TextToken as shown in the following code:

ANNTEXTTOKEN TextToken;

TextToken.uStructSize = sizeof(ANNTEXTTOKEN);

TextToken.cToken = 0;

TextToken.nTokenType = ANNTOKEN_SEPARATOR;

For a sample that illustrates how to define the text token table depicted above, see the example.

Required DLLs and Libraries

LTANN

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:

Class Members

Topics:

Annotation Functions: Object Properties

 

Implementing Annotations

 

Automated User Interface for Annotations

 

Annotation Functions: Creating and Deleting Annotations

 

Types of Annotations

 

Annotation Functions: Implementing Custom Annotations

 

Annotation Functions: Creating Custom Annotations

 

Fixed Annotations

 

Minimizing Flicker With Double Buffering

 

Annotation Functions: Working with the Toolbar

Example

// This example defines a new user token to display the current date in mm/dd/yyyy format

// It defines a second token for company name

// #D is the token

// Add this sample to the main annotation demo

// After running this sample:

// 1. Draw a text box

// 2. Right-click the text box

// 3. Display the text dialog

// 4. Click the "Insert Token" button

// 5. Choose the newly-defined tokens

L_INT LAnnAutomation_LAnnAutomation_InsertTextTokenTableExample(LAnnAutomation *pLAutomation) 
{
   L_INT nRet;
   ANNTEXTTOKEN TextToken; 
   // Clear the  current text token table
   nRet = pLAutomation->ClearTextTokenTable();
   if(nRet != SUCCESS)
      return nRet;
   memset(&TextToken, 0, sizeof(ANNTEXTTOKEN)); 
   TextToken.uStructSize = sizeof(ANNTEXTTOKEN); 
   // Define token for two digit month
   TextToken.cToken = '0'; 
   TextToken.pszDesc  = TEXT("Two Digit Month");
   TextToken.pszTokenString = NULL; 
   TextToken.nTokenType = ANNTOKEN_DATE_MM; 
   nRet = pLAutomation->InsertTextTokenTable(&TextToken); 
   if(nRet != SUCCESS)
      return nRet;
 
   // Define token for two digit day
   TextToken.cToken = '1'; 
   TextToken.pszDesc = TEXT("Two Digit Day");
   TextToken.pszTokenString = NULL; 
   TextToken.nTokenType = ANNTOKEN_DATE_DD; 
   nRet = pLAutomation->InsertTextTokenTable(&TextToken); 
   if(nRet != SUCCESS)
      return nRet;
 
   // Define token for four digit year
   TextToken.cToken = '2'; 
   TextToken.pszDesc = TEXT("Two Digit Day");
   TextToken.pszTokenString = NULL; 
   TextToken.nTokenType = ANNTOKEN_DATE_YYYY; 
   nRet = pLAutomation->InsertTextTokenTable(&TextToken); 
   if(nRet != SUCCESS)
      return nRet;
 
   // Add a separator
   TextToken.cToken = 0; 
   TextToken.pszDesc = NULL; 
   TextToken.pszTokenString = NULL; 
   TextToken.nTokenType = ANNTOKEN_SEPARATOR; 
   nRet = pLAutomation->InsertTextTokenTable(&TextToken); 
   if(nRet != SUCCESS)
      return nRet;
 
   // Define token for mm/dd/yyyy
   TextToken.cToken = 'D'; 
   TextToken.pszDesc = TEXT("Date: mm/dd/yyyy");
   TextToken.pszTokenString = TEXT("#0/#1/#2");
   TextToken.nTokenType = ANNTOKEN_TEXT; 
   nRet = pLAutomation->InsertTextTokenTable(&TextToken); 
   if(nRet != SUCCESS)
      return nRet;
 
   // Define token for company name
   TextToken.cToken = 'c'; 
   TextToken.pszDesc = TEXT("Company Name");
   TextToken.pszTokenString = TEXT("Your Company Name");
   TextToken.nTokenType = ANNTOKEN_TEXT; 
   nRet = pLAutomation->InsertTextTokenTable(&TextToken); 
   if(nRet != SUCCESS)
      return nRet;
 
   return SUCCESS;
}