|
-
Sep 18th, 2000, 03:21 PM
#1
"In Visual Basic, if one form shows another form modally, and the second form tries to unload the first form in either its Unload or Query_Unload event, Visual Basic hangs."
On January 5th, Microsoft said they were actively looking for a fix, I'm tired of waiting.
Does anyone have there own idea?
If form1 calls form2 (vbmodal) and I want to exit my app from form2 I use this code:
Dim Frm As Form
For Each Frm In Forms
Unload Frm
Set Frm = Nothing
Next Frm
The problem is that when it tries to unload form1 it will immediately try to unload form2 (on its own, not using the above routine) and hang. Any ideas?
Thanks!!
-
Sep 18th, 2000, 03:28 PM
#2
Yes,
1. Unload your forms in a diffent order.
2. Use "End"
I would not recommend using End as it will 'kill' your program and not unload anything. Like clicking the 'stop' button in the debugger.
Gerco Dries.
-
Sep 18th, 2000, 03:29 PM
#3
Try this, which unloads them backwards so that it's done in a last-loaded-first-unloaded way
Code:
For nNdx = Forms.Count - 1 To 0 Step -1
Unload Forms(nNdx)
Next
-
Sep 18th, 2000, 03:47 PM
#4
For some reason the QueryUnload is being called twice for certain forms. It doesn't matter if I use
For nNdx = Forms.Count - 1 To 0 Step -1
Unload Forms(nNdx)
Next
OR THIS
For Each Frm In Forms
Unload Frm
Set Frm = Nothing
Next Frm
Even if I 'stop' the app using the IDE my app still hangs on an exit.
-
Sep 18th, 2000, 04:56 PM
#5
-
Sep 19th, 2000, 08:33 AM
#6
'On error resume next' doesn't work either.
When QueryUnload tries to run the second time, the return value (UnloadMode) has a value of '5'. This value isn't listed in the return values for 'QueryUnload Event', only 0 through 4.
-
Sep 19th, 2000, 08:36 AM
#7
The MSDN library shows a return value of 5 as "A form is closing because its owner is closing."
-
Sep 19th, 2000, 09:17 AM
#8
Fanatic Member
I'm guessing here, so if i'm wrong please correct me.
I think maybe your problem lies in the parent-child relationship between the windows in your app.
By parent-child I mean how win32 platform interprets the windows in the app, not MDI.
i.e. the first window you load is the parent window, and then the second and third forms you load are child windows of that first window, so when you try to unload a parent from a child it's a cyclic call...
If this is the case, then maybe you've got to work out how to make all your forms independent windows of each other. If it's not the case then it was my best guess.
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Sep 19th, 2000, 11:25 AM
#9
Your theory is right cripsin. What I've had to do is unload each form as a new form opens. If I need to open a previously opened form I reload it and put the saved values back into the form when it opens. It's not the way I wanted to do things, but it's working.
Thanks for everyone's help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|