Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Restoring clipping region

Posted on 2000-03-16
5
Medium Priority
?
322 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 300 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

Independent Software Vendors: 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

879 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