Process and modify the text in the background

[Top]  [Chapter]  [Previous]  [Next]

... without any modification to the cursor position.

 

To do so, please use the method WPDLLInt1.Memo.EnumParagraphs.

 

You can use a special field object, i.e. "SUM" in the text.

 

The contents of this field object is then updated in the paint routine.

 

' Insert the 'SUM' field object

Private Sub Command2_Click()

   WPDLLInt1.TextCursor.InputFieldObject "SUM", "", "<-->"

End Sub

 

 

' here "SUM" is calculated

Private Sub WPDLLInt1_OnTextObjectGetText(ByVal Editor As LongByVal CurrPage As LongByVal Obj As WPTDynInt.IWPTextObj)

  If Obj.Name = "SUM" Then

      ' initialize a global variable with 0

      iSUMME = 0

      ' call WPDLLInt1_OnEnumParOrStyle and pass EventParam=1

      WPDLLInt1.Memo.EnumParagraphs False, 1

      ' show in the field object

      Obj.Params = Right$("      " + Format(iSUMME, "0.00"), 8)

  End If

End Sub

 

Private Sub WPDLLInt1_OnEnumParOrStyle(ByVal IsControlPar As BooleanByVal StartPos As LongByVal Count As LongByVal ParText As WPTDynInt.IWPParInterface, ByVal ParAttr As WPTDynInt.IWPAttrInterface, ByVal EventParam As Long, Abort As Boolean)

  Dim t As String

  t = ParText.GetText

  ' add to the global variable

  If EventParam = 1 Then

  

    If t <> "" Then

    iSUMME = iSUMME + CDbl(t)

    End If

  

  End If

End Sub

 


[process_and_modify_the_text_in.htm]    Copyright © 2007 by WPCubed GmbH