Solved

Restoring clipping region

Posted on 2000-03-16
5
317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

615 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