Re: Invalidate won't fire OnPaint??

From: Chris Taylor (chris_taylor_za_at_hotmail.com)
Date: 07/24/04


Date: Sat, 24 Jul 2004 20:11:22 +0300

Hi,

Glad I could help. From the performance that would depend, if you need
immediate updates then you will have to do a Refresh. If you are doing a
number of successive updates it might be better to delay the repainting
until all updates have completed. To do this you can call Invalidate for
each update and then once all the updates have completed you call Update
which forces all the invalidated regions to be repainted immediately, this
would work especially well if the updates are to different regions and each
invalidate passed the required region. The performance overhead would very
much depend on what you are doing in the drawing code.

-- 
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"kjon" <y@yy.co> wrote in message
news:eVZccOZcEHA.2408@tk2msftngp13.phx.gbl...
> Thanks Chris. At least things are a bit clearer to me now.
> So can I safely say that for my current situation, I'll need to use
> Refresh() instead of Invalidate()? Will that cause any speed problem?
> Thanks.
>
> Regards
>
>
> "Chris Taylor" <chris_taylor_za@hotmail.com> wrote in message
> news:eI%23opiYcEHA.3864@TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > The OnPaint event is fired in response to a WM_PAINT message in the
> windows
> > sub-system. Since the WM_PAINT message is a low priority messge all
other
> > messages will be excuted leaving the OnPaint to be potentially delayed.
By
> > calling Refresh you are effectively causing and invalidate on the client
> > area and forcing an immediate update. This corresponds to the windows
API
> > functions InvalidateRect and UpdateWindow.
> >
> > So in your case the call to Invalidate is causing a region to be
> invalidated
> > and posting a WM_PAINT message to the message queue, however other
> messages
> > are taking priority and being handled ahead of the WM_PAINT. When you
call
> > Refresh the region is invalidated and the WM_PAINT is delivered directly
> to
> > the windows procedure, bypassing the message queue and this causes an
> > immediate call to the Paint event handler.
> >
> > Hope this helps
> >
> > -- 
> > Chris Taylor
> > http://dotnetjunkies.com/weblog/chris.taylor
> >
> >
> > "kjon" <y@yy.co> wrote in message
> > news:enBaxFUcEHA.3096@tk2msftngp13.phx.gbl...
> > > Hi, I have a control which is inherited from user control. In my
> control,
> > > there is a public sub method that will do something and then call the
> > > invalidate() inside that method.
> > >
> > > But unfortunately, I find that even if I have the invalidate() inside
> the
> > > method, OnPaint is not called. But if I put Refresh() instead of
> > > Invalidate(), the OnPaint() is called.
> > >
> > > I wonder why is this happen? Should I use Refresh() instead of
> > Invalidate()?
> > > In my knowledge, I thought every Invalidate() will goto OnPaint(), is
> that
> > > right?
> > >
> > > Please help. Thanks in advance.
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: is it a newsgroup or marketplace? (was: What DNS to go for?)
    ... model for all of those free DNSes), I just need reliable DNS. ... What would happen when refresh period expires? ... business domain) if you just want to serve your local lan. ... updates or guarantees of consistency. ...
    (comp.os.linux.networking)
  • Re: Refresh() and Invalidate()
    ... Calling Refresh after an Invalidate call shouldn't cause your control to ... What I would expect to see is one Paint event (which means ... From MSDN's docs about Refresh: ...
    (microsoft.public.dotnet.framework.drawing)
  • RE: Need to requery a main form with a pop up form
    ... When you requery a form, a result of that action is the form will move to the ... Open you're popup form where you enter your payments in dialog mode. ... repaint updates the value of unbound calculated controls on your form. ... Depending on your needs, you may not need both refresh and repaint, so try ...
    (microsoft.public.access.gettingstarted)
  • Re: Refresh() and Invalidate()
    ... paint twice. ... So your control's entire client area would be invalidated, and since that would contain any region you passed to Invalidate, your Paint event would show the whole client area as invalid. ... Given what Refresh does, calling Invalidate and then immediately calling Refresh - regardless of whether you pass a region to Invalidate or not - is unnecessary; calling Refresh will get you there. ... Note that Refresh also causes a redraw of all child controls, which is an important distinction from Invalidate ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Graphics 102 : regional refresh of form/control
    ... method called Invalidate() that let's me invalidate any rectangular region of the Control. ... Does drawing a graphic (ala the Graphics class, for example the use of DrawLine()) automatically invalidate the graphic object's region? ... I then made it so the Refresh() method of the form was called for each graphic object. ... BUT - I'd like to be able to refresh only a portion (rectangular region) of the form for speed. ...
    (microsoft.public.dotnet.languages.vc)