Page 1 of 1

Ending tabulators cause error

Posted: Wed Aug 06, 2008 1:50 pm
by cmatusch
Hello,

if the content of a TRichViewEdit ends with a tabulator, I get the error
"Can't get or set this kind of information for this item" when I exit the TRichViewEdit.
The error comes from the
procedure TCustomRVData.GetTextInfo(ItemNo: Integer; var AText: String; var ATag: Integer); where I check, if the TRichViewEdit is empty or not.

Code: Select all

procedure TForm1.TextRTFExit(Sender: TObject);
var
  szHilfRTFText1: String;
  nHilfTag:       Integer;
begin
  KeyPreview := true;

  Text1RTF.GetCurrentTextInfo(szHilfRTFText1, nHilfTag);

  if (szHilfRTFText1 = '') then
    Label1.Caption := 'The RTF is empty.'
  else
    Label1.Caption := 'The RTF isn''t empty.'

end;

Thanks in advance for any help

Regards
Christian Matusch

Posted: Thu Aug 07, 2008 5:27 pm
by Sergey Tkachenko
GetCurrent*** methods return information about the item at the position of caret. GetCurrentTextInfo returns information for text item. If the caret is not in the text item (and tabulator is NOT a text item in TRichView), it raises the exception.
So this is by design.
What do you want to implement? Checking if TextRVF empty?
If yes, use this code:

Code: Select all

procedure TForm1.TextRTFExit(Sender: TObject); 
begin 
  if (Text1RTF.ItemCount=0) or
    ((Text1RTF.ItemCount=1) and ((Text1RTF.GetItemText(0)='') ) then
    Label1.Caption := 'The RTF is empty.' 
  else 
    Label1.Caption := 'The RTF isn''t empty.' 
end; 

Posted: Fri Aug 08, 2008 9:37 am
by cmatusch
That's the solution
Thanks