Handle form closing


E

Etienne Charland

I have an MDI form containing child forms. I want to handle form closing to
display a confirmation message when a form is closed or when the main form
is closed. However, the Closing even of the child forms is raised before the
Closing event of the MDI form when you close the MDI form. So, if I catch
the Closing event of the child forms and display a message, then catch the
Closing even of the main form, then I get 2 messages displayed.

Is there a way to know, when a child form is being closed, wether the user
closed the child form or the mdi form?

Thanks
Etienne
 
Ad

Advertisements

H

Haim

The only way I can think of right now is to catch the
MouseDown event of the parent window and check to see if
the mouse position is over the close button, if it is -
you can ask for approval and disable the event if the
user choose to cancel the form close.
I am sure there is a better way but at least it gives you
a full solution.

Haim.
 
Ad

Advertisements

W

Wiktor Zychla

U¿ytkownik "Etienne Charland said:
I have an MDI form containing child forms. I want to handle form closing to
display a confirmation message when a form is closed or when the main form
is closed. However, the Closing even of the child forms is raised before
the Closing event of the MDI form when you close the MDI form. So, if I
catch the Closing event of the child forms and display a message, then
catch the Closing even of the main form, then I get 2 messages displayed.

Is there a way to know, when a child form is being closed, wether the user
closed the child form or the mdi form?

http://tinyurl.com/5e4c9

Wiktor Zychla
 

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