form maximized event

G

Guest

Hi all

I am using form's ResizeEnd event to adjust some GUI staff on my form.
But when user maximizes the form, this event is not fired.
Theoretically, I could use Resize or SizeChanged events to catch when form
is maximized (or normalized from maximized state) but then I loose all
advantages provided by ResizeEnd because those two events are fired way to
often ...

Is there other way to add kind of "Maximize" / "Normalize" events withut
using Resize / SizeChanged ?

Thank you
Alex
 
P

Peter Duniho

I am using form's ResizeEnd event to adjust some GUI staff on my form.
But when user maximizes the form, this event is not fired.
Theoretically, I could use Resize or SizeChanged events to catch when
form
is maximized (or normalized from maximized state) but then I loose all
advantages provided by ResizeEnd because those two events are fired way
to
often ...

You should use Resize, but also handle ResizeBegin and ResizeEnd. In
ResizeBegin, set a flag, in ResizeEnd, clear the flag, and in Resize don't
do anything if the flag is set. That way you can handle the Resize event
for non-dragging scenarios, but not waste time doing things when the user
is dragging.

IMHO, it would be better if the Resize event had an EventArgs parameter
specific to the event, and which contained useful things like the new size
(which you could modify in order to constrain the sizing) as well as a
flag indicating whether you're in a ResizeBegin/End scenario.

Or alternatively, maybe the Form class could have just added a Resizing
event that was always followed by a Resize event, to easily differentiate
between some on-going sizing operation and a simple single-shot resize.

Or maybe they could have just used Resize only for resizing, and used the
SizeChanged event for reporting the actual change of the size.

But they didn't do any of the above...so as far as I know, you're stuck
setting a flag. :)

Pete
 
G

Guest

Thanks Peter it works!

Peter Duniho said:
You should use Resize, but also handle ResizeBegin and ResizeEnd. In
ResizeBegin, set a flag, in ResizeEnd, clear the flag, and in Resize don't
do anything if the flag is set. That way you can handle the Resize event
for non-dragging scenarios, but not waste time doing things when the user
is dragging.

IMHO, it would be better if the Resize event had an EventArgs parameter
specific to the event, and which contained useful things like the new size
(which you could modify in order to constrain the sizing) as well as a
flag indicating whether you're in a ResizeBegin/End scenario.

Or alternatively, maybe the Form class could have just added a Resizing
event that was always followed by a Resize event, to easily differentiate
between some on-going sizing operation and a simple single-shot resize.

Or maybe they could have just used Resize only for resizing, and used the
SizeChanged event for reporting the actual change of the size.

But they didn't do any of the above...so as far as I know, you're stuck
setting a flag. :)

Pete
 

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