Determine if child window has been closed

  • Thread starter Thread starter Markus Wildgruber
  • Start date Start date
M

Markus Wildgruber

Hi!

We have an Mdi-parent window and want to close all of its children. The user
should be able to cancel the closing-procedure (e.g. when the contents of
the child window have been modified and the user clicks 'cancel' in the
messagebox that asks if the contents should be saved).
How can we determine if the closing of the child window has been canceled
after calling the Close-method on the child window-object?

TIA,

Markus
 
Markus Wildgruber said:
We have an Mdi-parent window and want to close all of its children. The user
should be able to cancel the closing-procedure (e.g. when the contents of
the child window have been modified and the user clicks 'cancel' in the
messagebox that asks if the contents should be saved).
How can we determine if the closing of the child window has been canceled
after calling the Close-method on the child window-object?

You can check if the form should be closed in its 'Closing' event. Set
'e.Cancel = True' to cancel closing.
 
Hi!

Thanks for your reply, but there has been a little misunderstanding.
Our problem is not how to cancel the closing of the child window, we use the
Closing-event as you described.
We call childWindow.Close() in the Mdi-parent window. The window will be
closed (in most cases) but we can not be sure if that this is really the
case as the user is able to cancel the closing.

So, how can we determine whether the child window has been closed after the
call to childWindow.Close()?

TIA,

Markus
 
Markus Wildgruber said:
Thanks for your reply, but there has been a little misunderstanding.
Our problem is not how to cancel the closing of the child window, we use the
Closing-event as you described.
We call childWindow.Close() in the Mdi-parent window. The window will be
closed (in most cases) but we can not be sure if that this is really the
case as the user is able to cancel the closing.

So, how can we determine whether the child window has been closed after the
call to childWindow.Close()?

You can loop through the items in the MDI container's 'MdiChildren'
property and check if the form still exists there.
 
Back
Top