|
-
August 10th, 2001, 03:47 PM
#1
Detect # of forms opened automatically
Hi!
I would like to be able to automatically count the number of forms currently opened when the user clicks a menu item. How do I do this?
I basically want to make sure each child form is unloaded before i close the parent mdi form.
Any help is appreciated!
~goddess
[email protected]
"There are no stupid questions, but there are a lot of inquisitive idiots."
-
August 10th, 2001, 03:53 PM
#2
Re: Detect # of forms opened automatically
-
August 10th, 2001, 03:54 PM
#3
Re: Detect # of forms opened automatically
Hey there, see if this code does what you're looking for...
Dim frm as Form
for Each frm In Forms
if frm.MDIChild = true then Unload frm
next
I haven't tested that so I can't swear on my life that it will work but maybe get you in the right direction? Good luck!
Jeff
-
August 10th, 2001, 04:01 PM
#4
Re: Detect # of forms opened automatically
is there such a thing as an 'isLoaded' check? i think that would capture what I am trying to do.
The code you posted gave me an 'invalid property value' error, but it was a great idea!
~goddess
[email protected]
"There are no stupid questions, but there are a lot of inquisitive idiots."
-
August 10th, 2001, 04:02 PM
#5
Re: Detect # of forms opened automatically
Actually, I changed it to frm.visible = true then . . .
and it worked great!!
Thanks for the kick start!
~goddess
[email protected]
"There are no stupid questions, but there are a lot of inquisitive idiots."
-
August 10th, 2001, 04:10 PM
#6
Re: Detect # of forms opened automatically
Hahaha, I just tested some code with frm.Visible and it worked out so as I came back to post it for ya I noticed your message- great minds... 
-
August 11th, 2001, 11:41 AM
#7
Re: Detect # of forms opened automatically
This adds to what everyone else has posted:
in parent form:
option Explicit
private Sub MDIForm_Load()
' or form1.show if you want
Load Form1 'child
Load Form2 'child
Load Form3 'not a child
End Sub
private Sub MDIForm_QueryUnload(Cancel as Integer, UnloadMode as Integer)
Dim intCount as Integer
' unloads all forms
' note forms(0) is the parent form which as you know will be unloaded
' by the its own unload method
' The forms collection begins at 0 and Forms.Count gives the number of
' forms in the collection, so you need to -1
for intCount = (Forms.Count - 1) to 1 step -1
If Forms(intCount).MDIChild then
MsgBox Forms(intCount).Name & " is a child"
else
MsgBox Forms(intCount).Name & " is not a child"
End If
Unload Forms(intCount)
next
End Sub
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
|