Solved

Restoring clipping region

Posted on 2000-03-16
5
314 Views
Last Modified: 2010-04-04
I have a problem with the TPrinter object canvas and the clipping region.

I can not find the way to restore a clipping region after I set it up to something else.  I don't want to set it to a previus value, but to the original value.

In the TPrinter the printing area is set to the full page at start, but for my procedures I clip the region so they don't print outside what is settled.  The problem is that I'm not able to restore the clipping area when I finish.

What I do is exlude any already printing area for what is already printed, so next procedures don't overlay over previous areas.

My actual solution is to store the cliping area the first time I print, and that work ok if you don't change the paper size.

TIA
0
Comment
Question by:clopez
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:TheNeil
ID: 2622897
Why not just copy the original clipping region into a TRect and then assign it back when you've finished.

i.e.

VAR
  OldClip : TRect;
BEGIN
  ...
  OldClip := Printer.Canvas.ClipRect;
  ...
  Printer.Canvas.ClipRect := OldClip
  ...
END;

The Neil
0
 
LVL 10

Accepted Solution

by:
Lischke earned 100 total points
ID: 2623088
I think a better way is to let Windows save and restore the printer DC (which includes also clipping regions, as well as pens, brushes, paper orientation etc.):

var
  Save: Integer;

begin
  Save := SaveDC(Printer.Canvas.Handle);
  :
  RestoreDC(Printer.Canvas.Handle, Save);
end;

Very comfortable and reliable. Fast enough for usual tasks.

Ciao, Mike
0
 

Author Comment

by:clopez
ID: 2625358
What TheNeil says is what I am actually doing.  But I was looking for some thing like <b>RestoreClipArea</b>.  Any way find really interesting what Lischke states.
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2625560
Well, so try it out! It works very fine :-)

Ciao, Mike
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2627088
My idea stemmed from Delphi while Mike's is more API. All I can say is, I had trouble assigning a clipping region to the printer using my approach, so give Mike's idea a go (it's bound to be right)

The Neil =;)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mobile Keyboard covers the display of the TMemo 3 100
Convert GUI app into console app for Win32 Env 5 125
creating threads in delphi 1 156
Dynamically Created Query 3 69
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question