Ruler Units

General TRichView support forum. Please post your questions here
Post Reply
andyhill
Posts: 28
Joined: Tue May 23, 2006 8:22 pm

Ruler Units

Post by andyhill »

I have a TRVRuler bound to a TRichViewEdit control and find that the RichViewEdit1.LeftMargin / RichViewEdit1.RightMargin values after a RVRuler1.UpdateRulerMargins call do not reflect thier correct values in the Ruler grid that appears to show the pagewidth correct the first time only.

The Ruler PaperWidth seems to grow.

eg.

function MMtoScreenPixels(MM: Integer): Integer;
var
n: Single;
begin
n:= Screen.PixelsPerInch / 25.7;
Result:= Trunc(MM*n);
end;

EditorForm.RichViewEdit1.TopMargin:= MMtoScreenPixels(10);
EditorForm.RichViewEdit1.BottomMargin:= MMtoScreenPixels(10);
EditorForm.RichViewEdit1.LeftMargin:= MMtoScreenPixels(10);
EditorForm.RichViewEdit1.RightMargin:= MMtoScreenPixels(10);
//
EditorForm.RVPrint1.TopMarginMM:= 10;
EditorForm.RVPrint1.BottomMarginMM:= 10;
EditorForm.RVPrint1.LeftMarginMM:= 10;
EditorForm.RVPrint1.RightMarginMM:= 10;
//
EditorForm.RVRuler1.UpdateRulerMargins;

http://www.axfite.com.au/rvruler1.jpg 10mm

http://www.axfite.com.au/rvruler2.jpg 20mm (see PageWidth is now 23 instead of 21)

Am I doing anything wrong ?

The only way that I can make it work correctly is to

Save the Ruler Page Width first
pw:= EditorForm.RVRuler1.PageWidth;

Change the RichView Margins
EditorForm.RichViewEdit1.LeftMargin:= MMtoScreenPixels(10);
EditorForm.RichViewEdit1.RightMargin:= MMtoScreenPixels(10);

Update the Ruler Margins
EditorForm.RVRuler1.UpdateRulerMargins; // A4=21cm X 29.7cm

Restore the original Ruler Page Width
EditorForm.RVRuler1.PageWidth:= pw;

Is there a better way ?
Post Reply