trichview.support
Re: TRichViewEdit Character Count |
Author |
Message |
Sergey Tkachenko |
Posted: 02/08/2004 22:04:24 function GetCharacterCount(rv: TCustomRichView): Integer; function GetCharCount(RVData: TCustomRVData): Integer; var i, r, c, l, StyleNo: Integer; table: TRVTableItemInfo; begin Result := 0; for i := 0 to RVData.ItemCount-1 do begin StyleNo := RVData.GetItemStyle(i); if StyleNo>=0 then begin l := Length(RVData.GetItemText(i)); if rv.Style.TextStyles[StyleNo].Unicode then l := l div 2; inc(Result, l); end else if StyleNo = rvsTable then begin table := TRVTableItemInfo(RVData.GetItem(i)); for r := 0 to table.Rows.Count-1 do for c := 0 to table.Rows[r].Count-1 do if table.Cells[r,c]<>nil then inc(Result, GetCharCount(table.Cells[r,c].GetRVData)); end; end; end; begin Result := GetCharCount(rv.RVData); end; But I think it's not very good idea to call it in OnChange - it can be slow for large document. > What is the best way to get the Character Count of a TRichViewEdit control > from within the OnChange event? > > -Jason > > |
Powered by ABC Amber Outlook Express Converter