LAnnRTF::GetTextRTF

#include "ltwrappr.h"

virtual L_INT LAnnRTF::GetTextRTF(uFormat, pText, puLen)

L_UINT uFormat;

/* text format type */

L_TCHAR * pText;

/* address of character string to be updated */

L_SIZE_T * puLen;

/* address of a variable to be updated */

Gets the text and text length (unformatted text or rich text) of an ANNOBJECT_RTF annotation object.

Parameter

Description

uFormat

Value that specifies the text format type. Possible values are:

 

Value

Meaning

 

RTFFORMAT_TEXT

[0x0001] Retrieve the text as unformatted text.

 

RTFFORMAT_RTF

[0x0002] Retrieve the text as rich text.

pText

Pointer to a character string to be updated with the annotation object's character string. This value can be NULL.

puLen

Address of the variable to be updated with the length of the object's character string.

Returns

TRUE

There is a fixed annotation object in the client area.

FALSE

There are no fixed annotation objects in the client are

Comments

This function is used to retrieve the text from an ANNOBJECT_RTF object. The text can be retrieved either as rich text, or unformatted text.

Call this function twice. On the first call, pass NULL for the pText argument to get length of the required input buffer. Then, allocate a buffer and call the function a second time to retreive the text. The following code snippet illustrates the process:

   LAnnRTF lRTF;  // assume this is a valid ANNOBJECT_RTF object
   L_UINT uLength; 
   L_TCHAR *pText; 
   
   // Get the length
   lRTF .GetTextRTF(RTFFORMAT_RTF, NULL, &uLength); 
   
   // Allocate a buffer
   pText = (L_TCHAR *)malloc((uLength+1) * sizeof(L_TCHAR)); 
   
   // Retrieve the text
      lRTF .GetTextRTF(RTFFORMAT_RTF, pText, &uLength);

To get or set the text of other text objects, see the documentation for LAnnRTF::GetTextLen, LAnnRTF::GetText, and LAnnRTF::SetText.

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.

Platforms

Win32, x64.

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 sample gets the text from Rich Text annotation object in one of two formats (text, or rich text)

// plRTF: the Rich Text annotation object

// uFormat: the format of the retrieved text--one of

// RTFFORMAT_TEXT

// RTFFORMAT_RTF

L_INT LAnnRTF_GetTextRTFExample(LAnnRTF *plRTF, L_UINT uFormat) 
{
	L_INT nRet;
   L_SIZE_T uLength; 
   L_TCHAR *pText; 
   L_TCHAR szMsg[200]; 
   L_TCHAR *pszFormat; 
   
   switch(uFormat) 
   {
   case RTFFORMAT_TEXT: 
      pszFormat = TEXT("RTFFORMAT_TEXT");
      break; 
      
   case RTFFORMAT_RTF: 
      pszFormat = TEXT("RTFFORMAT_RTF");
      break; 
      
   default: 
      return FAILURE; 
      break; 
   }
   
   // Get the length
   nRet = plRTF->GetTextRTF( uFormat, NULL, &uLength); 
   if (nRet != SUCCESS) 
      return nRet; 
   
   pText = (L_TCHAR *)malloc((uLength+1) * sizeof(L_TCHAR)); 
   nRet = plRTF->GetTextRTF( uFormat, pText, &uLength); 
   if (nRet == SUCCESS) 
   {
      wsprintf(szMsg, TEXT("Format: %s\nLength: %d"), pszFormat, uLength); 
      MessageBox(NULL, pText, szMsg, MB_OK); 
   }
	else
		return nRet;
   
   free(pText); 
	return SUCCESS;
}