AnnRTFText example for Visual Basic
' This sample loads a rich text annotation object with text.
' It illustrates how AnnTextRTF can treat the text as Rich Text, or plain text.
' hObject: the Rich Text annotation object
' uFormat: the format of the retrieved text is one of the following:
' RTF_FORMAT_TEXT
' RTF_FORMAT_RTF
Private Sub SampleAnnTextRTF(hObject As Long, uFormat As Long)
Dim pszFormat As String
Dim RTF As String
Dim ulength As Long
Const RICH_STRING = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033" + _
"{\fonttbl{\f0\fnil\fcharset0 Arial;}}{\colortbl ;" + _
"\red255\green0\blue0;\red255\green255\blue255;" + _
"\red51\green102\blue0;\red0\green0\blue255;" + _
"\red0\green0\blue0;}\viewkind4\uc1\pard\cf1" + _
"\highlight2\ul\fs20 Rich \cf3\ulnone\b Text" + _
"\cf4\b0\i String\cf5\i0\par}"
Select Case uFormat
Case RTF_FORMAT_TEXT
pszFormat = "RTF_FORMAT_TEXT"
RasterAnn.Flags = 0
RasterAnn.AnnRTFText(hObject, uFormat) = RICH_STRING
Case RTF_FORMAT_RTF
pszFormat = "RTF_FORMAT_RTF"
RasterAnn.Flags = 0
RasterAnn.AnnRTFText(hObject, uFormat) = RICH_STRING
End Select
RTF = RasterAnn.AnnRTFText(hObject, uFormat)
ulength = RasterAnn.RTFTextLength
MsgBox "The Fomat Type is = " + pszFormat
MsgBox "The RTFTextLength = " + Str(ulength)
End Sub