Managing Resize Event?

D

Dave Veeneman

I'm creating a custom control that uses the OnPaint event to paint a
graphic. The graphic needs to resize itself when the control is resized.
Right now, I'm trapping the Resize event to trigger the paint. However, the
Resize event appears to fire repeatedly as the control is being resized,
which causes the control to repaint repeatedly, chewing up CPU capacity.

I'd like to have the control redraw only when the resize is complete, not
while it is in process. Is there a simple way to do this? Thanks.

Dave Veeneman
Chicago
 
O

ozbear

I'm creating a custom control that uses the OnPaint event to paint a
graphic. The graphic needs to resize itself when the control is resized.
Right now, I'm trapping the Resize event to trigger the paint. However, the
Resize event appears to fire repeatedly as the control is being resized,
which causes the control to repaint repeatedly, chewing up CPU capacity.

I'd like to have the control redraw only when the resize is complete, not
while it is in process. Is there a simple way to do this? Thanks.

Dave Veeneman
Chicago

I assume you are using the Invalidate method in your Resize handler to
cause the Paint to occur (or at least I hope you are rather than just
calling your Paint method).

I haven't tried this but you could try to catch the MouseUp event when
the user releases the mouse at the end of their resizing of the
control (that's the only way you can know that they are done anyway)
and Invalidate the control at that point? The Resize event handler
need only set a boolean variable to true, which the MouseUp event
handler would look at to determine whether to call Invalidate or not.

Oz
 
A

AlexS

Don't forget also to catch last keyboard click when resizing happens through
keyboard.
And some messages which could be sent to your window...
This will be fun...

HTH
Alex
 

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