Re: Invalidate won't fire OnPaint??
From: Chris Taylor (chris_taylor_za_at_hotmail.com)
Date: 07/24/04
- Next message: Pedro Almeida: "Flicker using XP styles (w/ .manifest file)"
- Previous message: kjon: "Re: Invalidate won't fire OnPaint??"
- In reply to: kjon: "Re: Invalidate won't fire OnPaint??"
- Messages sorted by: [ date ] [ thread ]
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. > > > > > > > > > > > >
- Next message: Pedro Almeida: "Flicker using XP styles (w/ .manifest file)"
- Previous message: kjon: "Re: Invalidate won't fire OnPaint??"
- In reply to: kjon: "Re: Invalidate won't fire OnPaint??"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|