Solved

RectInRgn()

Posted on 2000-03-07
6
202 Views
Last Modified: 2013-12-26
I am trying to prevent a Rect in a window from being redrawn if
not necessary. I tried the following code but it does not work
any suggestions. I tried putting the Draw_The_Window() within
Begin & End update and it didn't make a difference.

BTW: The code works fine when I don't check for the
RectInRgn().


case updateEvt:
BeginUpdate((DialogPtr)gMainEventRecord.message);                        
EndUpdate((DialogPtr)gMainEventRecord.message);
Draw_The_Window((DialogPtr)gMainEventRecord.message);
break;


void Draw_The_Window (DialogPtr theDialog)
{
DialogPeek            theDialogPeek;
Rect                  iconRect = {20, 32, 52, 64};

theDialogPeek - (DialogPeek)theDialog;
      
if( RectInRgn( &iconRect, theDialogPeek->window.updateRgn) )
      Display_Icon( theDialog );

}
0
Comment
Question by:gail_p
[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
  • 4
  • 2
6 Comments
 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2610963
BeginUpdate() immediately clears the update region, so that RectInRgn call will always return false. If you check against clipRgn instead this ought to work.

That's if you don't call EndUpdate() before calling your draw routine, because EndUpdate() sets the clipping region back to whatever it was before BeginUpdate() set it to the pending update region.

So move EndUpdate after the Draw_The_Window call, and check the clipping region instead of the update region, and you ought to be good to go.
0
 

Author Comment

by:gail_p
ID: 2615499
If I move Draw_The_Window() routine between the Begin and End Update the the PlotIconSuite() call in the Draw_The_Window() gets drawn over. That is why I put the Draw_The_Window() after the EndUpdate().
0
 
LVL 4

Accepted Solution

by:
Alex Curylo earned 50 total points
ID: 2616775
Check out the diagram at

http://developer.apple.com/techpubs/mac/Toolbox/Toolbox-207.html#MARKER-9-210

which shows how BeginUpdate() and EndUpdate() affect the clipping region of the window. If it's not working the way you expect, then something must be invalidating your window incorrectly.

A useful technique would be to put a call to FillRgn() on the update region in pink or something like that just before the BeginUpdate call; then you can see exactly what part of the window will be drawn over by calls within Begin/EndUpdate. If it's not what you expect, then something is wrong with your invalidation code and it ought to be fixed where the problem is instead of working around it at update time.
0
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!

 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2616792
And if you draw anywhere _other_ than between Begin/End update calls, don't forget to make sure to call ValidRect/ValidRgn as appropriate, otherwise yes of course it'll flicker because the Window Manager has no way to know what part of the window you don't want redrawn now.

But it's better to never draw except at update time to avoid all these kinds of problems.
0
 

Author Comment

by:gail_p
ID: 2617874
Great, thanks for the help. Any suggestions for my Balloon Help question?
0
 
LVL 4

Expert Comment

by:Alex Curylo
ID: 2617999
You're welcome. I'll go look at it now.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a Shell script to start a service checking the port 6 56
repeatSeparator  java  challenge 13 59
abstract class with all non abstract mentods 6 86
Problem to Office 1 62
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 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