DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   Watched TopicsWatched Topics     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A little bug in PrintPreview

 
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
Mixy
Member


Joined: 28 Dec 2005
Posts: 1
Location: Bulgaria

PostPosted: 28/12/05 10:51    Post subject: A little bug in PrintPreview Reply with quote

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

My solution is posted below:

Code:

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;
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 29/12/05 08:53    Post subject: Reply with quote

Thank you very much!
_________________
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

Add to favorites

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group