Re: howto avoid cdc drawing done not in onPaint to be erased?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Wed, 11 Jul 2007 10:09:13 -0400
There is no practical limit to the number of DCs you can have in WIn32. In Win16, it was
5.
I think what is going on here is worse than preoptimization. It is using a completely
incorrect model of programming for Windows, exacerbated by a complete misunderstanding of
how Windows works.
joe
On Wed, 11 Jul 2007 12:18:58 +0100, "David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Joseph M. Newcomer [MVP]
"Equilibrium" <ryariv@xxxxxxxxx> wrote in message
news:1184150113.833579.37210@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'll try to explain.
The reason i need all of this to perform outside the WM_PAINT message
is because the control is updated each 20ms with new object to
draw. the static control main goal is to display a tracking data , so
i recive x.y coordinates each 20ms , and on those coordinates
i need to draw something.
Storing those x,y in a string or an array and then caling WM_PAINT
(via invalidate) , and there to draw them, seems to me quite
expensive / wasteful , especially that the data can flow to the system
for along time.
In othere word what you are saying is, that if we are using the mouse
to free draw on a control ' we need to save each and every point the
mouse x,y position was.
What i need , basically is a way , when the disaplay need to be
"refresh\repaing" , to save the DC , and then restore it on WM_PAINT.
I don't fully understand what you're trying to do, but this may be the
reason why you DO need to paint by the standard mechanism.
If your owner draw button contains data members x, y, then you update (x,y)
when you need to, and call InvalidateRect().
1. Windows is very clever with WM_PAINT messages: it queues them behind
more important things, and amalgamates pending ones (IIRC). So if the
program is busy doing other things you may not get a paint message every
time you do an InvalidateRect(). So in fact you'll do less redrawing and
it will be less "wasteful".
2. What makes you think that doing things by sending messages is such a big
overhead? Sending a message to draw something is surely a minimal effort
compared with actually drawing it!
In circumstances like this I take the advice (attributed to Donald Knuth)
that "Premature optimisation is the root of all evil". Do it the proper
way and think about it further if it doesn't work well enough.
Otherwise how much code are you going to write to detect whether someone
else's window hasn't just covered yours? And do you really think it will
be more efficient than letting Windows do what it was designed to do?
[ Oh, and BTW, in the old days of Windows 3.1, hanging on to a DC a moment
longer than necessary was considered by many to be the worst crime in the
book. I haven't checked recently but Windows does manage those resources
carefully, and it is surely best to let it do so.]
Dave
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: howto avoid cdc drawing done not in onPaint to be erased?
- From: David Ching
- Re: howto avoid cdc drawing done not in onPaint to be erased?
- From: David Webber
- Re: howto avoid cdc drawing done not in onPaint to be erased?
- References:
- howto avoid cdc drawing done not in onPaint to be erased?
- From: Equilibrium
- Re: howto avoid cdc drawing done not in onPaint to be erased?
- From: David Webber
- Re: howto avoid cdc drawing done not in onPaint to be erased?
- From: Equilibrium
- Re: howto avoid cdc drawing done not in onPaint to be erased?
- From: David Webber
- howto avoid cdc drawing done not in onPaint to be erased?
- Prev by Date: Re: howto avoid cdc drawing done not in onPaint to be erased?
- Next by Date: Re: Manifests and requestedExecutionLevel
- Previous by thread: Re: howto avoid cdc drawing done not in onPaint to be erased?
- Next by thread: Re: howto avoid cdc drawing done not in onPaint to be erased?
- Index(es):