Solved

Restoring clipping region

Posted on 2000-03-16
5
304 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now