Page 1 of 1

TPrintPreview - different display on different screens

PostPosted: August 28th, 2005, 4:41 pm
by Tim
Hello,

thanks a lot for creating the TPrintPreview Component, without it I surely couldn't implement a Preview in my program, because I'm still not so experienced in programming.
I use v4.61 and Delphi 2005.

Here's my problem:

I write my program on a Notebook under WinXP and the following display settings: 1280X800
With this configuration everything runs, but if I execute the program on other PCs with different monitors and display settings (e.g. Win2000 1024x768 or 1280x1024) the text on the preview-paper has always different sizes and dimensions.

I tried to handle with some lengthening coefficients but it didn't work always correctly.
Is there any possibility to convert the text to the right dimensions on each PC?

PostPosted: August 28th, 2005, 6:17 pm
by Johnny_Bit
You know... your resolution is wide-screen type. I think if there's something wrong with font displaying is on your side than others (mine programs on every computer they're runned looks good)

PostPosted: August 29th, 2005, 4:53 pm
by Tim
I thought too, that it is a fault in my code.
But if I send the print-job directly to a printer not to PrintPreview, the dimensions are the same regardless of which PC I use.

Here is an example how I tried to print:

Code: Select all
    with PrintPreviewPersonalauswertung do
      begin
        Orientation:= poLandscape;
        PaperType:=   pA4;
        BeginDoc;

        SetMapMode(Canvas.Handle, MM_LOMETRIC);  // 1/10 mm
       
        randlinks:=    200;     // border left
        randoben:=     150;   // top
        randunten:=    150;   // bottom

        Canvas.Font.Size:= 12;
        zhoehe:= Canvas.Font.Size * Canvas.Font.PixelsPerInch / 72    // line height
        y:= randoben;                 

        Canvas.Pen.Color:= clBlack;
        Canvas.Brush.Color:= clWhite;

        Canvas.Font.Name:='Arial';
        Canvas.Font.Style:=[fsbold];

        Canvas.TextOut(randlinks, y*-1, 'TimeControl Personalauswertung ' + jahr);
        y:= y + zhoehe;

        ...
        ...

        EndDoc;


Please check it if something is wrong, or post an example how to print correctly with TPrintPreview (like in your programs).

Thanks!

PostPosted: August 29th, 2005, 5:00 pm
by Kambiz
The problem could be because of the following call:

Code: Select all
SetMapMode(Canvas.Handle, MM_LOMETRIC);

Instead, use Units property of the PrintPreview to set your desired mapping mode. By the way, Set Units property before calling BeginDoc.

Cheers

PostPosted: August 29th, 2005, 5:04 pm
by Kambiz
By the way, instead of calaculating zhoehe variable in that way, simply use:

Code: Select all
zhoehe := -Canvas.Font.Height;

The screen's pixels per inch is not always 72, and in the other hand, the pixel per inch could vary in PrintPreview.

PostPosted: August 29th, 2005, 5:23 pm
by Tim
That's it :D !


I deleted
Code: Select all
SetMapMode(Canvas.Handle, MM_LOMETRIC);

and now everything works fine!

Thanks a lot for your help!