473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MDI Child Window Closing event not raised

MDIChild Window Closing event not raised when MDI Parent is in a class
library!

Intructions to recreate problem:
1. Create a ClassLibrary project
2. Add an MDIParent form and a form that will be an MDIChild form
3. In the Closing event of both forms add debug code so that you can
see when they are called
<MDI PARENT FORM CODE>
Private Sub MDIParent_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Debug.WriteLine("MDIParent_Closing " & Now & " " &
e.Cancel.ToString)
End Sub

Private Sub MDIParent_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim f As New MDIChild
f.MdiParent = Me
f.Show()
End Sub

<MDI CHILD FORM CODE>
Private Sub MDIChild_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Debug.WriteLine("MDIChild_Closing " & Now & " " &
e.Cancel.ToString)
End Sub
4. Add a Windows Application to act as the client and set the
reference:
<MODULE1 CODE>
Sub Main()
Dim f As New ClassLibrary1.MDIParent
f.ShowDialog()
End Sub

5. Run the application. Click the X close button on the MDIParent and
you will see that the MDIParent_Closing event fires but not the
MDIChild!

If you put the MDIParent and MDIChild in a Windows application, it all
works ok!
Nov 20 '05 #1
2 2439
"chris in grimsby" <gr************@lycos.com> schrieb
4. Add a Windows Application to act as the client and set the
reference:
<MODULE1 CODE>
Sub Main()
Dim f As New ClassLibrary1.MDIParent
f.ShowDialog()
End Sub

replace
f.ShowDialog()
by
application.run(f)

An Mdi Form is not a dialog. Dialogs behave differntly.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #2
"chris in grimsby" <gr************@lycos.com> schrieb
If you put the MDIParent and MDIChild in a Windows application, it
all works ok!


Here there's no difference. As long as you use showdialog, the closing event
of the child does not fire, no matter where the forms are.
--
Armin

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Dalberg | last post by:
I have a closed box system which opens an html page. The page closes by the system. I have access to the html page. I added code to open a child window from this page. However when the parent...
2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
2
by: Jon | last post by:
I am writing an MDI app that uses a document manager class to keep track of opened child windows. I want the user to be able to close a child window, but then re-open the window from the "Window"...
1
by: JH | last post by:
When the user tries to close a child window, I want to use the Closing event to hide the window instead and cancel the close. How can I cancel the window from closing? Thanks.
5
by: Iain | last post by:
I would like to prevent the user from closing MDI child windows. However, I would like them to be able to minimize and maximize them. Setting the Control Box to false removes the minimize and...
1
by: al | last post by:
Hi, I have MDI form with 4 mdichild forms. I would like to enable Windows menu-item as more than 1 mdichild form loads. The problem i'm having is when MdiChildActivate event is raised, it does...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
13
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the...
4
by: reemamg | last post by:
From a parent window a new child window is open with window.open <script type="text/javascript" language="JavaScript" > function abc() { if(window.event.clientY <0 &&...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.