472,354 Members | 2,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

MDIForm Parent/Child forms BEST Practice

Hi everyone,

could someone give me some thoughts on the best way to manage mdi
parent and child forms?

in vb6 i could scroll through the forms collection and determine which
forms were open/closed and their current state. now i can't.

before i didn't have to declare numerous named instances each time i
loaded or unloaded a form.

if i open a child form from another child form and try to assign
mdimain as the mdiparent it doesn't permit it, if i say f1.mdiparent =
me.mdiparent i get memory problems (as have others judging from the
groups).

all my current forms are declared public shared in mdiMain, but should
these be in a user made forms collection owned by a global module
(cMain)?

if i am finished with a child form, i want to unload it, not hide it,
but if i close a form in vb.net it extinguishes the instance.

when the mdi parent closes, i would like the app to terminate.

should i be setting mdi children to nothing or disposing them?

basically, what can/should i do to get the same mdi parent/child
management present in vb6 while still preserving the smallest
footprint possible in memory?

all comments/code greatly appreciated. i am probably not the only
programmer to ponder this question.

regards

Edwinah63
Nov 20 '05 #1
6 9305
I don't know if w i do is the best way of doing things but it works. i'll
try to put it under your questions.

"Edwinah63" <ed*****@customercare.com.au> wrote in message
news:d7*************************@posting.google.co m...
Hi everyone,

could someone give me some thoughts on the best way to manage mdi
parent and child forms?

First i always create a public var of my main form (mdi parent) for easy
access (yust declare it in a module and i the parent.load set the var to me)
in vb6 i could scroll through the forms collection and determine which
forms were open/closed and their current state. now i can't.

something like this?
For Each f As Form In fmMain.MdiChildren
If f.Visible Then

End If
Next

before i didn't have to declare numerous named instances each time i
loaded or unloaded a form.
the named instance is declared locally so once you are out of this sub it is
gone
Dim manPSNT As New frmManPSNType
manPSNT.MdiParent = Me
manPSNT.Show()
if i open a child form from another child form and try to assign
mdimain as the mdiparent it doesn't permit it, if i say f1.mdiparent =
me.mdiparent i get memory problems (as have others judging from the
groups).

I use the public instance of my main form to do this. But i have don it w
the me.MdiParent should work. (unless you are doing strange things in the
client forms, try loading them non mdi first)
all my current forms are declared public shared in mdiMain, but should
these be in a user made forms collection owned by a global module
(cMain)?
you that would be more organized but generally you don't need them all
if i am finished with a child form, i want to unload it, not hide it,
but if i close a form in vb.net it extinguishes the instance.
sounds right you will have to assign a new instance of the form to the var,
it all depends on w you want to do at that givven time.
when the mdi parent closes, i would like the app to terminate.
try this

Private Sub frmMain_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
Application.Exit()
End Sub
should i be setting mdi children to nothing or disposing them?
..NET will do that for you

basically, what can/should i do to get the same mdi parent/child
management present in vb6 while still preserving the smallest
footprint possible in memory?
if you want less mem don't declare all your forms as globals, .NET handles
it rather good the standard way.

all comments/code greatly appreciated. i am probably not the only
programmer to ponder this question.

regards

Edwinah63

There are probably bether ways to do some things, comments are welcome.
Hope it helps a bit

Eric
Nov 20 '05 #2
"Edwinah63" <ed*****@customercare.com.au> schrieb
Hi everyone,

could someone give me some thoughts on the best way to manage mdi
parent and child forms?

in vb6 i could scroll through the forms collection and determine
which forms were open/closed and their current state. now i
can't.
You have the MdiChildren property in the MDI form.
before i didn't have to declare numerous named instances each time
i loaded or unloaded a form.
If you don't need to handle them specifically, an array, or Arraylist or
whatever would be sufficient. Or the mentioned Mdichildren property.
if i open a child form from another child form and try to assign
mdimain as the mdiparent it doesn't permit it, if i say f1.mdiparent
= me.mdiparent i get memory problems (as have others judging from
the groups).

all my current forms are declared public shared in mdiMain, but
should these be in a user made forms collection owned by a global
module (cMain)?
I'd keep them in the MDI parent. I'd not even declare them public, but
instead pass references if needed.
if i am finished with a child form, i want to unload it, not hide
it, but if i close a form in vb.net it extinguishes the instance.

when the mdi parent closes, i would like the app to terminate.

should i be setting mdi children to nothing or disposing them?
No, not necessary. The children are closed before the parent is closed, and
closed forms are also disposed automatically.
basically, what can/should i do to get the same mdi parent/child
management present in vb6 while still preserving the smallest
footprint possible in memory?

all comments/code greatly appreciated. i am probably not the only
programmer to ponder this question.


I'm not sure what's exactly your problem. I don't have memory problems. If I
wanted to create and later access an object (like a Form), I'd declare a
variable to store the reference. You can create one variable per Form
(advantage: don't have to search for it in a collection) or store them all
in a collection (advantage: no single variables needed), or both. Or use a
Hashtable to store them. If there can be only one instance of each Form
class, you could use the class name as the key (form.gettype.fullname).
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
yust a side note
when the mdi parent closes, i would like the app to terminate.

should i be setting mdi children to nothing or disposing them?
No, not necessary. The children are closed before the parent is closed,

and closed forms are also disposed automatically.

This has coused problems for me in the past (on a standard create parent
first and do everithing in childs it should work) but it dousn't hurt to use
this
Private Sub frmMain_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
Application.Exit()
End Sub
eric
"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de... "Edwinah63" <ed*****@customercare.com.au> schrieb
Hi everyone,

could someone give me some thoughts on the best way to manage mdi
parent and child forms?

in vb6 i could scroll through the forms collection and determine
which forms were open/closed and their current state. now i
can't.
You have the MdiChildren property in the MDI form.
before i didn't have to declare numerous named instances each time
i loaded or unloaded a form.


If you don't need to handle them specifically, an array, or Arraylist or
whatever would be sufficient. Or the mentioned Mdichildren property.
if i open a child form from another child form and try to assign
mdimain as the mdiparent it doesn't permit it, if i say f1.mdiparent
= me.mdiparent i get memory problems (as have others judging from
the groups).

all my current forms are declared public shared in mdiMain, but
should these be in a user made forms collection owned by a global
module (cMain)?


I'd keep them in the MDI parent. I'd not even declare them public, but
instead pass references if needed.
if i am finished with a child form, i want to unload it, not hide
it, but if i close a form in vb.net it extinguishes the instance.

when the mdi parent closes, i would like the app to terminate.

should i be setting mdi children to nothing or disposing them?


No, not necessary. The children are closed before the parent is closed,

and closed forms are also disposed automatically.
basically, what can/should i do to get the same mdi parent/child
management present in vb6 while still preserving the smallest
footprint possible in memory?

all comments/code greatly appreciated. i am probably not the only
programmer to ponder this question.
I'm not sure what's exactly your problem. I don't have memory problems. If

I wanted to create and later access an object (like a Form), I'd declare a
variable to store the reference. You can create one variable per Form
(advantage: don't have to search for it in a collection) or store them all
in a collection (advantage: no single variables needed), or both. Or use a
Hashtable to store them. If there can be only one instance of each Form
class, you could use the class name as the key (form.gettype.fullname).
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
"EricJ" <er********@ThiSbitconsult.be.RE> schrieb
yust a side note
when the mdi parent closes, i would like the app to terminate.

should i be setting mdi children to nothing or disposing them?
No, not necessary. The children are closed before the parent is
closed,

and
closed forms are also disposed automatically.


This has coused problems for me in the past (on a standard create
parent first and do everithing in childs it should work) but it
dousn't hurt to use this
Private Sub frmMain_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
Application.Exit()


If it's really necessary as you say, I'd use Application.ExitThread.
End Sub

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

If it's really necessary as you say, I'd use Application.ExitThread.


noted and changed in 2 apps ;) tnx

eric
Nov 20 '05 #6
thanks guys for your thoughts.

Edwina
Nov 20 '05 #7

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

Similar topics

6
by: Debi | last post by:
Hi, I added a few buttons to the Mdi form, to call the child forms in the button click event. But when the child window opens, all the buttons are displayed in front of the child window. Any...
0
by: amber | last post by:
Help! In my project, I have a 'navigation' form that opens first, and from there the user chooses from multiple 'modules'. Each module has a 'main' form that contains a menu to open many...
25
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
2
by: Jim Shank | last post by:
I am really trying to find the best OOP way of doing this. I have a parent MDI form with multiple children and I am trying to communicate variables between them. I have been able to successfully...
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...
2
by: JohnR | last post by:
Let's say I have an MDI parent form with a textbox. If I create an MDI child form and, at runtime, move the MDI child window over the textbox on the MDI parent, the textbox appears in front of the...
2
by: Ben | last post by:
after I migrated to dotNet, code wizard never bothered upgraded my MDIform background embedded pictures b/c MS is no longer providing us with that feature. Is there an alternative solution that...
6
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
What would cause VS2005 Pro to lose all of my MdiForm Design information? I've been working on one of the Child Forms and having problems with the Child Form's threads not completing (locking up...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...

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.