Function TWPCustomRtfEdit.CodeMoveTo(AName:string; Code:TWPTextObjType; CmpModes:TWPTextObjModes; LocateOptions:TWPCodeLocateOptions) : Boolean

Unit: WPCTRMemo
Class: WPCTRMemo.TWPCustomRtfEdit

Parameters

Returns

The type of the result value is Boolean.

Description

This function moves the cursor at a certain code. It compares the name if it is not '*ALL*', the type and checks wether the mode and the given CmpModes have union elements. CmpModes Is not checked if = [].
You can also search for an Object TAG - in this case the tag has to be passed as IntToStr in the parameter AName. If you need to also compare the Name, append the integer after a '#' sign.
procedure TWPMiniEd.BookListClick(Sender: TObject); begin if (BookList.ItemIndex>=0) and WPRichText1.CodeMoveTo( Format('%s#%d',[BookList.Items[BookList.ItemIndex], Integer(BookList.Items.Objects[BookList.ItemIndex])]), wpobjBookmark, [wpobjIsOpening], [wpCompareName,wpCompareObjTag] ) then begin LastActiveRTFEdit(WPRichText1).ShowCursor; LastActiveRTFEdit(WPRichText1).SetFocus; end else ShowMessage('Bookmark was not found'); end;
The Listbox used above was filled with this code:
procedure TWPMiniEd.WPRichText1AfterLoadText(Sender: TObject); var lst : TWPTextObjList; i : Integer; begin lst := WPRichText1.CodeListTags(wpobjBookmark,'*ALL*', true); TRY BookList.Items.Clear; for I := 0 to lst.Count-1 do BookList.Items.AddObject(lst[i].Name, Pointer(lst[i].Tag) ); FINALLY lst.Free; END; end;