A little bug in PrintPreview

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

A little bug in PrintPreview

Postby Mixy » December 28th, 2005, 10:51 am

I found a little bug in PrintPreview - the printable area (function TPrintPreview.GetPrinterPageBounds: TRect) is not calculated correctly.

My solution is posted below:

Code: Select all
function TPrintPreview.GetPrinterPageBounds: TRect;
var
  Offset: TPoint;
  DPI: TPoint;

  // -- Mixy --
  PrintAreaX,
  PrintAreaY: integer;

begin
  Result := PageBounds;
  if PrinterInstalled then
  begin
    Offset.X := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX);
    Offset.Y := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY);
    DPI.X := GetDeviceCaps(Printer.Handle, LOGPIXELSX);
    DPI.Y := GetDeviceCaps(Printer.Handle, LOGPIXELSY);
    Offset.X := ConvertUnits(Offset.X, DPI.X, mmPixel, Units);
    Offset.Y := ConvertUnits(Offset.Y, DPI.Y, mmPixel, Units);

    // -- Mixy --
    PrintAreaX:=GetDeviceCaps(Printer.Handle, HORZRES);
    PrintAreaY:=GetDeviceCaps(Printer.Handle, VERTRES);
    PrintAreaX:=ConvertUnits(PrintAreaX, DPI.X, mmPixel, Units);
    PrintAreaY:=ConvertUnits(PrintAreaY, DPI.X, mmPixel, Units);

   // InflateRect(Result, -Offset.X, -Offset.Y);

    // -- Mixy --
    Result.Left:=Offset.X;
    Result.Top:=Offset.Y;
    Result.Right:=Offset.X+PrintAreaX;
    Result.Bottom:=Offset.Y+PrintAreaY;

  end;
end;
User avatar
Mixy
Member
Member
 
Posts: 1
Joined: December 28th, 2005, 10:44 am
Location: Bulgaria

Postby Kambiz » December 29th, 2005, 8:53 am

Thank you very much!
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2405
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron