Page 1 of 1
not save the last page blank
Posted: Wed Jul 08, 2015 1:38 pm
by Ceprotec
which command to use to position cursor in row 1 column 1 the last page of text?
After positioning the cursor, make a function to see if that page is blank or spaces to the end?
Objective: Do not allow the User save the text with the last page blank.
thanks
Posted: Thu Jul 09, 2015 12:24 pm
by Sergey Tkachenko
Do you use ScaleRichView, or TRichViewEdit+TRVPrint?
Posted: Thu Jul 09, 2015 8:29 pm
by Ceprotec
I use ScaleRichView
Posted: Thu Jul 16, 2015 5:24 pm
by Sergey Tkachenko
In ScaleRichView, you can simply call
Code: Select all
SRichViewEdit1.CurrentPage := SRichViewEdit1.PageCount;
This code moves the caret to the beginning of the last page.
This procedure removes all spaces and tabs at the end of the document:
Code: Select all
procedure TrimBottom(SRichViewEdit1: TSRichViewEdit);
var i, ItemNo: Integer;
Edit: TCustomRichViewEdit;
begin
ItemNo := -1;
Edit := SRichViewEdit1.RichViewEdit;
// deleting empty items at the end of the document
for i := Edit.ItemCount-1 downto 1 do
if ((Edit.GetItemStyle(i)<0) and (Edit.GetItemStyle(i)<>rvsTab)) or
((Edit.GetItemStyle(i)>=0) and (Trim(Edit.GetItemText(i))<>'')) then begin
ItemNo := i;
break;
end;
if ItemNo<0 then
exit;
if Edit.GetItemStyle(ItemNo)=rvsListMarker then
inc(ItemNo);
inc(ItemNo);
Edit.DeleteItems(ItemNo, Edit.ItemCount-ItemNo);
// removing spaces from the end of the last text item
ItemNo := Edit.ItemCount-1;
if Edit.GetItemStyle(ItemNo)>=0 then
Edit.SetItemText(ItemNo, TrimRight(Edit.GetItemText(ItemNo)));
Edit.Format;
Edit.ClearUndo;
end;
This procedure cannot be undone. If you want a similar procedure as an undoable editing operation, let me know.