Toggle Header

Public forum for discussing TScaleRichView (shareware addon to TRichView providing WYSIWYG editing)
Post Reply
don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

Toggle Header

Post by don709 » Sun Apr 19, 2015 3:00 pm

This is a small procedure called from a button click event on the form to toggle the header on or off.
It seems to have stopped working and I have no idea why.
RVE is of type TSRichViewEdit
Not completely sure it it has to do with my updating to the Delphi XE7 version. From reading the forum posts on headers it seems that the commands to change displaying a header has changed but I can't seem to get it to display. Any ideas would be appreciated.

Code: Select all

procedure TFormTextEditor.AddHeaderButtonClick(Sender: TObject);
begin
  if IsEmpty(RVE.RVHeader) then
  begin
    if FileExists(ExeDir+'MedicalTemplates\Header.rtf') then
    begin
      RVE.RVHeader.LoadRTF(ExeDir+'MedicalTemplates\Header.rtf');
      RVE.Format;
    end;
  end
  else
  begin
    RVE.RVHeader.Clear;
    RVE.Format;
  end;
  RVE.RichViewEdit.Modified := True;
end;

Sergey Tkachenko
Site Admin
Posts: 13468
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Sun Apr 19, 2015 5:58 pm

Headers and footers were reworked in the last major update of ScaleRichView. The changes are related to implementation of separate headers for the first page and odd/even pages.

If you need to toggle visibility, you can (like in older versions) simply assign
RVE.PageProperty.HeaderVisible.

If you want to change the header content in code, your code is not correct in the new version of ScaleRichView.
In older versions, header was not only edited, but also stored in RVE.RVHeader. In the new version, it is stored in RVE.SubDocuments[]; RVHeader contains the header only while editing it.

So you can:
1) make sure that a header is not being edited (call RVE.StartEditing(srvrveMain))
2) Call RVE.SubDocuments[srvhftNormalHeader].LoadRTF (or Clear), then RVE.Format;

Alternatively, you can:
1) make sure that a header is being edited (call RVE.StartEditing(srvrveHeader))
2) change RVE.RVHeader
3) if you made changes by non-editing methods, like Clear or LoadRTF, call RVE.RVHeader.Change, then RVE.Format.

don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

First page only

Post by don709 » Wed Apr 22, 2015 10:13 am

The following code works as expected

Code: Select all

    if IsEmpty(RVE3.RVHeader) then
    begin
      if FileExists(ExeDir+'MedicalTemplates\Header.rtf') then
      begin
        RVE3.StartEditing(srvrveMain);
        RVE3.SubDocuments[srvhftNormalHeader].LoadRTF('Header.rtf');
        RVE3.Format;
        RVE3.PageProperty.HeaderVisible := true;
      end;
    end
    else
    begin
      RVE3.RVHeader.ClearAll;
      RVE3.StartEditing(srvrveMain);
      RVE3.SubDocuments[srvhftNormalHeader].Clear;
      RVE3.Format;
      RVE3.PageProperty.HeaderVisible := false;
    end;
However if I use srvhftFirstPageHeader no header appears.

RVE3.SubDocuments[srvhftFirstPageHeader].LoadRTF('Header.rtf');
instead of
RVE3.SubDocuments[srvhftNormalHeader].LoadRTF('Header.rtf');

I assumed changing srvhftNormalHeader to srvhftFirstPageHeader would give me the header only on the first page... any idea what I'm doing wrong.

Thanks
Don

Sergey Tkachenko
Site Admin
Posts: 13468
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko » Wed Apr 22, 2015 12:36 pm

To show header and footer for the first page, assign RVE.PageProperty.TitlePage := True;
To show header and footer for even pages, assign RVE.PageProperty.FacingPages := True;

Post Reply