On Tue, 13 May 2008 07:40:38 -0700, Sin Jeong-hun <ty*******@gmai l.com>
wrote:
I have created a simple custom control, which displays a string data
on it. It draws the string at its OnPaint(). When the string is
changed I can call Invalidate() to redraw the string. Sort of simple.
But I guess it might not be efficient.
Unless you run into an actual performance issue, don't worry about it.
The fact is, this is the standard mechanism used by practically every
Windows control. Generally, invalidating a region of a control that's not
visible will indeed have no effect. The OnPaint() won't even be called.
But even if it is called, drawing a control that's not visible is MUCH
faster than drawing one that is. Most of the time, doing this sort of
additional drawing should not cause any sort of noticeable performance
issue.
Just keep doing it the way you're doing it now. In the unlikely event
that you do start to notice some sort of performance issue, then you can
start measuring your code to find out where and what exactly is causing
the performance problem, and _then_ if it turns out that the invalidation
of the control is causing it, you can worry about how to deal with it. I
predict that this chain of conditions will never come to pass. :)
Pete