trichview.support
Re: Enumerate text |
Author |
Message |
gerard |
Posted: 03/01/2004 15:32:14 Thanks, this works fine, except for one thing: when I change a style for a word, Processword will be called again with the same phrase. I try to show whet I mean: I have added a memo field to the TWordColorer and assigned it in Run. My processword is like this: function TWordColorer.ProcessWord: Boolean; begin SelectCurrentWord; FMemo.Lines.Add(FWord); FEdit.ApplyTextStyle(1); Result := True; end; Now when I process for example this text in RichEdit: The TRichEditView is a wonderful component and I change the style of every word this appears in my memo: The TRichEditView is a wonderful component TRichEditView is a wonderful component TRichEditView is a wonderful component is a wonderful component a wonderful component wonderful component component Since I am changing the style of 70 % of the words this slows down considerably. This does not happen when I do not change the style. How can I make that a processed word is not processed again when I have changed the style ? For completeness the source code I am using: type TWordColorer = class (TRVWordEnumerator) private FEdit: TCustomRichViewEdit; FMemo: TMemo; public procedure Run(Edit: TCustomRichViewEdit; Memo: TMemo); function ProcessWord: Boolean; override; end; function TWordColorer.ProcessWord: Boolean; begin SelectCurrentWord; FMemo.Lines.Add(FWord); FEdit.ApplyTextStyle(1); Result := True; end; procedure TWordColorer.Run(Edit: TCustomRichViewEdit; Memo: TMemo); begin FEdit := Edit; FMemo := Memo; inherited Run(Edit, rvesFromStart); end; procedure TForm1.Button1Click(Sender: TObject); var wc: TWordColorer; begin rve.LoadText('test.txt', 0, 0, True); rve.Format; LockWindowUpdate(rve.Handle); wc := TWordColorer.Create; try wc.Run(rve, memo1); finally wc.Free; LockWindowUpdate(0); end; end; |
Powered by ABC Amber Outlook Express Converter