The OnPaint method is run when the application recieves a WM_PAINT message.
The WM_PAINT message is sent when the application has invalid rectangles and
the application is about to enter an idle state.
Calling OnPaint directly may cause more painting than is needed and might be
completely useless because you'd still have to call BeginPaint and EndPaint
to clear the invalid rectangles out of the current list.
Call Invalidate with or without specifying the rectangles and allow the
system to do it's job without upsetting the flow.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Chan" <11*@111.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Invalidate() is a member of System.Windows. Forms.Form. It marks an area of
the client window as invalid and, therefore, in need of repainting, and
then
makes sure a Paint event is raised.
But why we are doing it this way. If we know that something needs
painting,
why don't
we just call OnPaint() or some other method to do the painting directly?
Thank you very much