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;
  R, R0: TRect;
  MyRgn: HRGN
  with PrintPreview do
   R0:=Canvas.ClipRect; {somehow, R0 is greatly different from R}
   OneCM := ConvertXY(100, 100, mmLoMetric, Units);
  InflateRect(R, -(OneCM.X), -(OneCM.Y)); {target region}
  MyRgn := CreateRectRgn(R.Left,,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}


//Mod Edit: phpBB's code tag is hard to use, eh?
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.
User avatar
Posts: 2410
Joined: March 7th, 2003, 7:10 pm

Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 4 guests