How do I catch the event that happen when the minimize icon is clicked

T

tony

Hello!

I have a mainManu where I can chose to display some window forms.
When the mainMenu is minimized I need to minimize every window form that is
started from the mainMenu.
So I need to catch the event that is trigged when the little underscore(the
minimize icon) up to the right is clicked.

I need to catch this event because all my child window forms must also be
minimized

I can't find any suitable method that I can use.

Is it possible to do it in another way then catch minimize event.

//Tony
 
T

Tom Porterfield

tony said:
Hello!

I have a mainManu where I can chose to display some window forms.
When the mainMenu is minimized I need to minimize every window form that
is started from the mainMenu.
So I need to catch the event that is trigged when the little
underscore(the minimize icon) up to the right is clicked.

I need to catch this event because all my child window forms must also be
minimized

I can't find any suitable method that I can use.

Is it possible to do it in another way then catch minimize event.

You can override OnSizeChanged and query the forms WindowState. Ex:

protected override void OnSizeChanged(EventArgs e)
{
switch (this.WindowState)
{
case FormWindowState.Minimized:
// minimize my other forms
break;
case FormWindowState.Maximized:
case FormWindowState.Normal:
// only put code here if there is a requirement to do something
(do you need to restore minimized forms?)
break;
default:
break;
}

// Don't forget to call base
base.OnSizeChanged (e);
}

If this is a requirement, have you considered making your app MDI?
 
T

tony

Hello!!

Thanks for your answer. I want to ask one more thing about this.

I have one mainMenu and then I display some window form by chosing some from
the menu.
We can assume that the window forms chosen from the menu is called A and B.
When the main Menu is minimized window form A and B is also minimized that's
what I wanted. That works fine.

Now to my question : When the mainMenu is displayed again so to speak back
to normal state window form A and B should also be displayed.
How can that be dome?

//Tony
 

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