[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

How are several Invalidate() calls processed???

Teis Draiby

1/5/2005 5:16:00 PM

What happens if I call the Invalidate(Rectangle) method several times
between two OnPaint() calls?
- is the resulting invalidated rectangle then added together from each
Invalidate(Rectangle)
- or are the calls queued to be executed later by one OnPaint() per
Invalidate(), causing an overhead if the rectangles overlap?

Put differently:
Do I gain in performance if I manually add together rectangles to be
invalidated if I already know that these rectangles are mainly overlapping -
rather than calling Invalidate(Rectangle) several times?

- Hope that I explain myself

Thank you very much!
Teis


2 Answers

Bob Powell

1/5/2005 5:34:00 PM

0

Invalidate calls the InvalidateRect Win32 API under the hood so the
rectangle is added to the list of invalid rects and left there until a
WM_PAINT message comes along.

WM_PAINT might arrive because of the normal message loop activity or because
Refresh was called. That forces a repaint.

Essentially there is no performance hit if you invalidate several rectangles
between paint cycles.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"Teis Draiby" <teisREMOVE-THIS@draiby.com> wrote in message
news:Ob9GJp08EHA.2700@TK2MSFTNGP14.phx.gbl...
> What happens if I call the Invalidate(Rectangle) method several times
> between two OnPaint() calls?
> - is the resulting invalidated rectangle then added together from each
> Invalidate(Rectangle)
> - or are the calls queued to be executed later by one OnPaint() per
> Invalidate(), causing an overhead if the rectangles overlap?
>
> Put differently:
> Do I gain in performance if I manually add together rectangles to be
> invalidated if I already know that these rectangles are mainly
> overlapping -
> rather than calling Invalidate(Rectangle) several times?
>
> - Hope that I explain myself
>
> Thank you very much!
> Teis
>
>


Teis Draiby

1/5/2005 7:03:00 PM

0

Thanks yet again, Bob!

regards, Teis


> Invalidate calls the InvalidateRect Win32 API under the hood so the
> rectangle is added to the list of invalid rects and left there until a
> WM_PAINT message comes along.
>
> WM_PAINT might arrive because of the normal message loop activity or
because
> Refresh was called. That forces a repaint.
>
> Essentially there is no performance hit if you invalidate several
rectangles
> between paint cycles.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing

> > What happens if I call the Invalidate(Rectangle) method several times
> > between two OnPaint() calls?
> > - is the resulting invalidated rectangle then added together from each
> > Invalidate(Rectangle)
> > - or are the calls queued to be executed later by one OnPaint() per
> > Invalidate(), causing an overhead if the rectangles overlap?
> >
> > Put differently:
> > Do I gain in performance if I manually add together rectangles to be
> > invalidated if I already know that these rectangles are mainly
> > overlapping -
> > rather than calling Invalidate(Rectangle) several times?
> >
> > - Hope that I explain myself
> >
> > Thank you very much!
> > Teis