gail_p
asked on
RectInRgn()
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)gMa inEventRec ord.messag e);
EndUpdate((DialogPtr)gMain EventRecor d.message) ;
Draw_The_Window((DialogPtr )gMainEven tRecord.me ssage);
break;
void Draw_The_Window (DialogPtr theDialog)
{
DialogPeek theDialogPeek;
Rect iconRect = {20, 32, 52, 64};
theDialogPeek - (DialogPeek)theDialog;
if( RectInRgn( &iconRect, theDialogPeek->window.upda teRgn) )
Display_Icon( theDialog );
}
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)gMa
EndUpdate((DialogPtr)gMain
Draw_The_Window((DialogPtr
break;
void Draw_The_Window (DialogPtr theDialog)
{
DialogPeek theDialogPeek;
Rect iconRect = {20, 32, 52, 64};
theDialogPeek - (DialogPeek)theDialog;
if( RectInRgn( &iconRect, theDialogPeek->window.upda
Display_Icon( theDialog );
}
ASKER
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().
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
But it's better to never draw except at update time to avoid all these kinds of problems.
ASKER
Great, thanks for the help. Any suggestions for my Balloon Help question?
You're welcome. I'll go look at it now.
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.