Ending tabulators cause error

General TRichView support forum. Please post your questions here
Post Reply
cmatusch
Posts: 2
Joined: Wed Aug 06, 2008 1:37 pm

Ending tabulators cause error

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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; 
cmatusch
Posts: 2
Joined: Wed Aug 06, 2008 1:37 pm

Post by cmatusch »

That's the solution
Thanks
Post Reply