TPrintPreview - different display on different screens

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

TPrintPreview - different display on different screens

Postby Tim » August 28th, 2005, 4:41 pm

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?
Tim
Active Member
Active Member
 
Posts: 5
Joined: August 28th, 2005, 4:02 pm
Location: Germany

Postby Johnny_Bit » August 28th, 2005, 6:17 pm

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)
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Tim » August 29th, 2005, 4:53 pm

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!
Tim
Active Member
Active Member
 
Posts: 5
Joined: August 28th, 2005, 4:02 pm
Location: Germany

Postby Kambiz » August 29th, 2005, 5:00 pm

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
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Kambiz » August 29th, 2005, 5:04 pm

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Tim » August 29th, 2005, 5:23 pm

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!
Tim
Active Member
Active Member
 
Posts: 5
Joined: August 28th, 2005, 4:02 pm
Location: Germany


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 2 guests

cron