Header height

General TRichView support forum. Please post your questions here
Post Reply
don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

Header height

Post by don709 »

When I load a header from an rtf file into a SRichViewEdit only the first couple of lines are showing and the rest is clipped.
A lot of white space above the lines.
Even when I clear the header and double click into it the header height is abnormally high.
It had been working fine until this abnormal height issue started.

I've tried clearing the header but this doesn't do anything.
RVE.RVHeader.Clear;
RVE.RVHeader.Format;

While debugging I notice that when the rvf file is first loaded the RVE.TopMarginPix is 60 and after the rvf file is loaded its 105

I tried setting the TopMargixPix to 60 when clearing the header but that seems to be a read only variable and causes an error message on compile.

Obviously my question is how do I reset the header back to some default height so that my header file loads in full view again.

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

Post by Sergey Tkachenko »

call ScaleRichView.Format instead of ScaleRichView.RVHeader.Format.
don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

Header Height

Post by don709 »

No change... In a different SRichViewEdit in the same procedure on a different PageControl tab this header loads fine. As it did with this one until the height grew and I'm not sure how it happened.

Even when I clear the header and double click into it the height is completely out of wack... regardless if I load the header.rtf or not.

Here is the code. (RVE is a TSRichViewEdit)
In the else statement I'd like to simple reset the header to some default height.

if IsEmpty(RVE.RVHeader) then
begin
if FileExists(ExeDir+'MedicalTemplates\Header.rtf') then
begin
RVE.RVHeader.Clear;
RVE.RVHeader.DeleteUnusedStyles(True,True,True);
RVE.RVHeader.LoadRTF(ExeDir+'MedicalTemplates\Header.rtf');
RVE.RVHeader.Format;
RVE.RichViewEdit.Modified := True;
end;
end
else
begin
RVE.RVHeader.Clear;
RVE.Format;
RVE.RichViewEdit.Modified := True;
end;
end;
Sergey Tkachenko
Site Admin
Posts: 17521
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

In this code, you still call RVE.RVHeader.Format instead of RVE.Format;
don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

Header height

Post by don709 »

Right... I had only changed it to RVE.Format in the else statement.
Now it's changed in both places but still no difference.

It has something to do with the rvf file itself because if I open the file with ActionTest and when I double click the header it opens up to be the same abnormal height.

It's only a 1 page test file... maybe you could be so kind as to have a look at it for me.
http://www.donwalsh.com/test.zip

I guess my problem is that I don't know how it happened and I need some code to fix it when it does. By fix it I guess I mean make the header come back to a normal default height.

Thanks for taking the time to answer my posts.
Don
Sergey Tkachenko
Site Admin
Posts: 17521
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

See the page setup dialog. You can see that the header height (and the footer height) = 10 cm.
If the header/footer is empty, this value is ignored. When it is being edited or non-empty, these values are respected (but not completely: they are to large for A4 page, so TSRichViewEdit uses 1/4 of page height (as far as I remember)).
(in code, they are SRV.PageProperty.HeaderY and FooterY properties).
don709
Posts: 13
Joined: Sun Apr 22, 2012 4:26 pm

Post by don709 »

Still no idea how this happened or how to fix it from within the program.

This is what I did find...
As I said I use 2 different SRichViewEdit in the same screen on 2 different PageControl Pages. As you suggested I checked the PageProperty.HeaderY in both and they were the same, both the working one and the one with the abnormal header height.

Still no closer to an answer and beginning to spend way to much time on the problem, which was putting me way behind schedule here the nasty fix I came up with.

Each time the program saves the file it is saved in both rvf and rtf format. So I opened the good and the bad rtf in NotePad++ and found the headers to be completely different.

File with abnormal header:
{\rtf1\ansi\ansicpg0\uc1\deff0\deflang0\deflangfe0\paperw11906\paperh16838\margl1984\margr850\margt1417\margb1417\headery5669\footery5669\viewscale112\viewzk2
{\fonttbl{\f0\fnil Arial;}{\f1\fnil Courier New;}{\f2\fnil Times New Roman;}{\f3\fnil\fcharset2 Symbol;}{\f4\fnil Arial Unicode MS;}{\f5\fnil\fcharset0 tahoma;}{\f6\fnil ms sans serif;}{\f7\fnil\fcharset0 times new roman;}{\f8\fnil\fcharset0 ms sans serif;}{\f9\fnil\fcharset0 cambria;}{\f10\fnil\fcharset0 Arial;}{\f11\fnil\fcharset0 garamond itc t;}{\f12\fnil\fcharset0 calibri;}{\f13\fnil Symbol;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\red64\green128\blue128;\red255\green255\blue206;\red128\green64\blue0;\red0\green0\blue0;\red153\green180\blue209;\red240\green240\blue240;\red231\green204\blue165;\red52\green18\blue46;\red248\green225\blue165;\red218\green180\blue122;}{\*\listtable{\list\listtemplateid1110066945\listsimple1
{\listlevel\levelnfc23\leveljc0\li360\fi-360\jclisttab\tx360{\leveltext\'01\'b7;}{\levelnumbers;}\f13\fs24}
\listid1602251529}
}
{\*\listoverridetable
{\listoverride\listid1602251529\listoverridecount0\ls1}
}
{\header
\pard\fi0\li0\ql\ri0\sb0\sa0\itap0 \plain \f0\fs20 \par}{\footer
\pard\fi0\li0\ql\ri0\sb0\sa0\itap0 \plain \f0\fs20 \par}


File with normal header:
{\rtf1\ansi\ansicpg0\uc1\deff0\deflang0\deflangfe0\paperw11906\paperh16838\margl1984\margr850\margt1417\margb1417\headery567\footery567\viewscale145\viewzk2
{\fonttbl{\f0\fnil Arial;}{\f1\fnil\fcharset0 garamond itc t;}{\f2\fnil\fcharset0 times new roman;}{\f3\fnil\fcharset0 arial;}{\f4\fnil\fcharset0 calibri;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
{\header
\pard\fi0\li0\ql\ri0\sb0\sa0\itap0 \plain \f0\fs20 \par}{\footer
\pard\fi0\li0\ql\ri0\sb0\sa0\itap0 \plain \f0\fs20 \par}


I did a simple copy and paste to overwrote the bad header with the good one then changed the source code to open the new rtf instead of the rvf. Then saved it as rvf. Closed the program and reset the source code back to open rvf and it worked. Header back to normal.

This has to be the nastiest fix ever but it worked.
At least now I know if it happens in the field I can fix it but it would certainly be a lot nicer to have a line of code in the program to reset a nasty header.
Sergey Tkachenko
Site Admin
Posts: 17521
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) Make sure that not only SRV.PageProperty.HeaderY&FooterY are equal, but also SRV.UnitsProgram are equal

2) What version of ScaleRichView do you use? Probably, some old version of TSRichViewEdit had a bug of not converting HeaderY and FooterY when assigning UnitsProgram.
Post Reply