Page 1 of 1

memo.InsertPageBreak and memo.RemoveCurrentPageBreak

Posted: Wed Feb 07, 2007 4:42 pm
by j&b
Hello,

I want to use the same button to make insertPageBreak and RemoveCurrentPageBreak.

I don't kow how I have to ask in an IF ... else part.

Jürgen

Posted: Thu Feb 08, 2007 8:45 am
by Sergey Tkachenko

Code: Select all

var ItemNo: Integer;
  PB: Boolean;
begin
  if memo.InplaceEditor<>nil then
    exit; // do not add page breaks in table cells
  
  ItemNo := memo.CurItemNo;
  if memo.OffsetInCurItem > memo.GetOffsBeforeItem(ItemNo) then
    PB := False // we are not at the beginning of item, 
                // so we are not at the beginning of paragraph
  else begin
    if (ItemNo>0) and (memo.GetItemStyle(ItemNo-1)=rvsListMarker) then
      dec(ItemNo);
    PB := memo.PageBreaksBeforeItems[ItemNo];
  end;
  if PB then
    memo.RemoveCurrentPageBreak
  else
    memo.InsertPageBreak;
end;