Page 1 of 1

TPRINTPREVIEW DRAWING RECTANGLE ISSUE NEW TEST 5.10

PostPosted: January 20th, 2009, 7:59 am
by sonigam
Hi Kambiz,

I noticed that changing the
units properties of the component in design time, properties
PAPERHEIGTH AND PAPERWIDTH are not
updated with the new units,
I have to change the PaperType
and then reset the desired Papertype
to refresh the PAPERHEIGTH AND PAPERWIDTH

This procedure in Vers. 5.10
work well, but I have to make some strange settings

Procedure MyDraw;

Procedure MyRect(L,T,R,B : Integer);
Begin
With PrintPreview Do
Begin
Canvas.Pen.Width := 1;
Canvas.Pen.Style :=psSolid;
L:=ConvertX(L*10, mmLoMetric, Units);
T:=ConvertY(T*10, mmLoMetric, Units);
R:=ConvertX(R*10, mmLoMetric, Units);
B:=ConvertY(B*10, mmLoMetric, Units);

// everything is correct, notice R+1,B+1 all lines of then rectangles, have
// same thickness
PrintPreview.Canvas.Rectangle(L,T,R+1,B+1);

// not correct, without R+1,B+1 the internal lines of rectangles
// have a greater thickness
PrintPreview.Canvas.Rectangle(L,T,R,B); //

End;
End;

Begin // MyDraw

With PrintPreview do
Begin
UsePrinterOptions:=False;
units:=mmpixel;
PaperType=pA3;
PaperType=pA4; // refresh the PAPERHEIGTH AND PAPERWIDTH in mmpixel pA4
// without these two settings(pA3,pA4) the preview does not display the data well in my pA4

Begindoc;
MyRect(20,20,30,30); MyRect(30,20,40,30);
MyRect(20,30,30,40); MyRect(30,30,40,40);
Enddoc;
End;
End; // MyDraw;

If I specific units other than mmpixel,
you always see rectangles with sides in common
more marked

Thanks again for your interest

Re: TPRINTPREVIEW DRAWING RECTANGLE ISSUE NEW TEST 5.10

PostPosted: January 20th, 2009, 9:58 am
by Kambiz
Thanks for the report.

I'll inform you here when I released the update.

Re: TPRINTPREVIEW DRAWING RECTANGLE ISSUE NEW TEST 5.10

PostPosted: January 22nd, 2009, 12:08 pm
by Kambiz
To fix the units problem, on line #4103 replace Units with Value.

The are some considerations when the value of Units property is not mmPixels.

  • When using an expression like Rect.Right+1, the rectangle width is not increased by one pixel, it is increased by one unit.
  • When Pen.Width is 1, it mean one unit thickness not one pixel thickness. In addition, one unit may appear as one pixel or more. It depends on DPI of your canvas (screen DPI is usually 96) and the zoom factor (in PrintPreview).
  • When Pen.Style is not psInsideFrame, Windows draws the line centered in the specified coordinate. When width of pen (physically) is more than on pixel, the half of the line's thickness is drawn outside the specified coordinate.
  • When Pen.Width is zero, the pen's thickness is always one pixel regardless of the current mapping mode, canvas DPI, and PrintPreview zoom factor.