Graphics 102 : regional refresh of form/control

P

Peter Oliphant

I now have graphics being drawn in the Paint event of my form (yeah, and
it's very cool). Problem was that it only updated any changes to these
graphics when Paint was called.

So, I then made it so the Refresh() method of the form was called for each
graphic object. In this case it drew just fine, but Paint was being called
so often I lost control of the form (e.g., trying to close the form using
the close 'x' in upper right corner resulted in an hour-glass icon and no
action). I then made it so it only called refresh once every so often. Now
all is good...

BUT - I'd like to be able to refresh only a portion (rectangular region) of
the form for speed. I notice all the .NET Control's can do this. I also
don't think the Control's Refresh() has an overloaded version that
establishes the rectangle of refresh.

Is there a 'region refresh' for controls (or possibly just for containers or
forms), and what is it if it does exist?

Thanks in advance! : )

[==P==]
 
P

Peter Oliphant

Ok, I may have a partial answer to my own question. There is a Control
method called Invalidate() that let's me invalidate any rectangular region
of the Control. So this is what I was looking for.

BUT - does this mean that Refresh() only refreshes invalidated areas? Does
drawing a graphic (ala the Graphics class, for example the use of
DrawLine()) automatically invalidate the graphic object's region? If so, I
don't need to do anything more than what I'm already doing! : )

[==P==]
 
R

Rob Schieber

Peter said:
Ok, I may have a partial answer to my own question. There is a Control
method called Invalidate() that let's me invalidate any rectangular region
of the Control. So this is what I was looking for.

BUT - does this mean that Refresh() only refreshes invalidated areas? Does
drawing a graphic (ala the Graphics class, for example the use of
DrawLine()) automatically invalidate the graphic object's region? If so, I
don't need to do anything more than what I'm already doing! : )

[==P==]

I now have graphics being drawn in the Paint event of my form (yeah, and
it's very cool). Problem was that it only updated any changes to these
graphics when Paint was called.

So, I then made it so the Refresh() method of the form was called for each
graphic object. In this case it drew just fine, but Paint was being called
so often I lost control of the form (e.g., trying to close the form using
the close 'x' in upper right corner resulted in an hour-glass icon and no
action). I then made it so it only called refresh once every so often.
Now all is good...

BUT - I'd like to be able to refresh only a portion (rectangular region)
of the form for speed. I notice all the .NET Control's can do this. I also
don't think the Control's Refresh() has an overloaded version that
establishes the rectangle of refresh.

Is there a 'region refresh' for controls (or possibly just for containers
or forms), and what is it if it does exist?

Thanks in advance! : )

[==P==]
Peter,

InvalidateRect and Update seem to be the winning combo for me. I'm not
sure what the offical answer is though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top