Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Restoring clipping region

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

Technology Partners: 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

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…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

670 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