TPrintPreview : Cliprect

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

TPrintPreview : Cliprect

Postby callostfound » May 26th, 2007, 8:12 pm

First, many thanks to Kambiz for creating such a great Delphi component.

I have a problem in printing a large network map (a set of points and lines). I want to print only a portion of the map. So I used SelectClipRgn to change the ClipRect property of the printpreview canvas. PrintPreview seemed to display the resulting image correctly, but printed an empty page when I clicked on the print button. Not sure what caused the problem and how to solve the problem.

Any input is highly appreciated.

Below please find my code for this:

Code: Select all
///////////////////////////////////////////////////////////////////
procedure CreateMyPage;
var
  R, R0: TRect;
  MyRgn: HRGN
  with PrintPreview do
  begin
   R:=PageBounds;
   R0:=Canvas.ClipRect; {somehow, R0 is greatly different from R}
   OneCM := ConvertXY(100, 100, mmLoMetric, Units);
  end;
  InflateRect(R, -(OneCM.X), -(OneCM.Y)); {target region}
 
  MyRgn := CreateRectRgn(R.Left,R.top,R.Right,R.Bottom);

  SelectClipRgn(PrintPreview.Canvas.Handle, MyRgn); {change ClipRect}
  MapBoard.SetupPrintBoard (PrintPreview.Canvas); {pass canvas }
  MapBoard.Print; {MapBoard draw map objects here}
  SelectClipRgn(PrintPreview.Canvas.Handle, 0); {Restore default ClipR}
  DeleteObject(MyRgn);
End;
////////////////////////////////////////////////////////////

Jack

//Mod Edit: phpBB's code tag is hard to use, eh?
callostfound
Member
Member
 
Posts: 1
Joined: May 26th, 2007, 6:29 pm

Postby Kambiz » May 27th, 2007, 1:27 pm

The DC represented by Canvas property depends on value of State property. When State is psCreating, the Canvas property represents the metafile canvas of the current page. Otherwise it's the printer canvas.

I hope this helps you to solve the problem.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron