MDI Child Window References being Set to Nothing


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: MDI Child Window References being Set to Nothing

  1. #1
    Kevin Baker Guest

    MDI Child Window References being Set to Nothing


    I have a question that should be easy for a VB .NET guru:

    Fact: VB .NET supports creating MDI apps with menu merging etc. Instructions
    are in the VS .Net Beta 2 Help.

    Question:
    When creating child windows is it important to write code that stores references
    to them, or will it be OK to simply be OK let the MDI plumbing, maintain
    references to them (i.e. the mechanism behind the MDI Window list)?

    Explanation (if question not clear):
    Why I worry about this is: (I have an MFC Doc/View perspective)
    If I don't maintain an array of references to the child windows, I worry
    that Garbage Collection will claim them. (so far it hasn't happened)
    Yet, if I do maintain my own array of references, I find that some of them
    are eventually set to Nothing if I force GC (even though I have not closed
    the child windows). For example, I might have 10 child windows up but have
    only 5 valid references in my array of references. If it turns out that
    the MDI plumbing is maintaining the references, and I can't, I'll need to
    figure out how to access this list of child window references.

    Thanks, Hope I have not confessed to complete ignorance.

  2. #2
    Kathleen Dollard Guest

    Re: MDI Child Window References being Set to Nothing

    Kevin,

    We like complete ignorance, it makes for easy questions (now, that was a
    joke, if I need a smiley, you need another cup of coffee <g>)

    The MDI parent keeps a reference to your child and you can access it through
    that. Similarly the MDI child knows its parent. You do not generally need
    your own list, although if you maintain your own list, nothing in the .Net
    infrastructure will remove items from your list. If you do not find a simple
    programming bug on your part doing that and can reproduce it, please insure
    that it gets reported as a bug.

    Non-MDI apps often need to maintain a list as the old VB Forms collection is
    gone.

    You can forget garbage collection, as it will only take out the trash on
    items that you could not get to if you tried (completely inaccessible
    objects).

    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center