resize events on windows form

T

Tarren

Hi:

I am trying to get access to the event after a window has been resized. The
events I have been using SizeChanged and Resize all fire after any pixel
size change.

What I am trying to achieve is after the window has been dragged to a new
size (or maximized/restored) then I redraw the images within the form.

If I do it on Resize, then it tries to redraw as the form is being resized,
which is not what I want. Is there some way I can get to the event and fire
only after they are done resizing?

Thanks.
 
Z

zacks

Hi:

I am trying to get access to the event after a window has been resized.  The
events I have been using SizeChanged and Resize all fire after any pixel
size change.

What I am trying to achieve is after the window has been dragged to a new
size (or maximized/restored) then I redraw the images within the form.

If I do it on Resize, then it tries to redraw as the form is being resized,
which is not what I want.  Is there some way I can get to the event and fire
only after they are done resizing?

Set a flag (boolean variable) to true in the Resize event. Then, in
the MouseUp event, check the flag. If true, reset to false, and
perform your resizing code.
 
T

Tarren

thanks! I will try that out


Hi:

I am trying to get access to the event after a window has been resized.
The
events I have been using SizeChanged and Resize all fire after any pixel
size change.

What I am trying to achieve is after the window has been dragged to a new
size (or maximized/restored) then I redraw the images within the form.

If I do it on Resize, then it tries to redraw as the form is being
resized,
which is not what I want. Is there some way I can get to the event and
fire
only after they are done resizing?

Set a flag (boolean variable) to true in the Resize event. Then, in
the MouseUp event, check the flag. If true, reset to false, and
perform your resizing code.
 
A

Andrus

Set a flag (boolean variable) to true in the Resize event. Then, in
the MouseUp event, check the flag. If true, reset to false, and
perform your resizing code.

Why you recommend so sophisticated solution ?

Form has ResizeEnd event which is designed for this. So your trick is not
required.

Andrus.
 
Z

zacks

Why you recommend so sophisticated solution ?

Form has ResizeEnd event which is designed for this. So your trick is not
required.

I was not familiar with the ResizeEnd event.

If nothing else, it would be a good exercise to do. Helps to
understand form event handling.
 
C

Charles Calvert

[...]
If I do it on Resize, then it tries to redraw as the form is being
resized, which is not what I want. Is there some way I can get to the
event and fire only after they are done resizing?

Yes. Handle the ResizeEnd event instead of Resize or SizeChanged.

Note that if you're handling this in the form class itself, you should
override OnResizeEnd instead. The documentation states "The
OnResizeEnd method also allows derived classes to handle the event
without attaching a delegate. This is the preferred technique for
handling the event in a derived class."
 

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