Handle form closing

  • Thread starter Thread starter Etienne Charland
  • Start date Start date
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
 
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.
 
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
 
Back
Top