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
not save the last page blank
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
In ScaleRichView, you can simply call
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:
This procedure cannot be undone. If you want a similar procedure as an undoable editing operation, let me know.
Code: Select all
SRichViewEdit1.CurrentPage := SRichViewEdit1.PageCount;
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;