Results 1 to 2 of 2

Thread: MDI Parent/Children Forms/Coding

  1. #1

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    MDI Parent/Children Forms/Coding

    Hi everyone.

    Priors: Using MS VC# 2008 Express on a Windows XP SP3 system

    I'm playing around with utilizing MDI Forms for an application I'd like to write. Knowing some things about the actual production application, I'm trying to implement them to test them out but I'm running into a few issues hence my post.

    First and foremost, one of the things I'd like to accomplish is something that I've found helps users out a bit and that's making non-active windows in a multiple-window environment translucent. I wrote an application like that a while ago and it turned out a little better than what I thought. However there's a slight problem with doing this to MDI children forms and it think it has to do with my relying on the focus mechanism for forms. My conclusion at this point is that MDI children never really have direct control over their focus since they belong to a MDI parent form which would control the attribute. I'm not sure if this is actually the case but if anyone could give me some pointers on this I'd appreciate it.

    One last thing I'd like to address is a seemingly "slacker" method of doing things but I just can't figure it out. I've written a class that has the sole purpose of managing a list of objects (this "list" is actually a dictionary) so that it could not only be portable but avoid a global dictionary variable just hanging around. As of right now, an instance of this class is initialized when the MDI parent form is created. My problem comes in when I pull up a child form to create and initialize an instance of the object I want to manage and add it to the dictionary. Shouldn't the dictionary object be visible to all children forms of the parent or is this the wrong type of thinking?
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: MDI Parent/Children Forms/Coding

    You're talking about two quite different topics here. In future, please keep each thread to a single topic and each topic to a single thread.

    With regards to the first question, MDI child forms do not support transparency in Windows Forms. Transparency is easier to accomplish in WPF but there's no MDI implementation in WPF, so you'd have to fake it.

    With regards to the second question, you can assign your dictionary to a public field/property in a module if you want it to be visible everywhere. That said, in a "proper" MDI implementation the child windows should ever be aware of each other's existence. Anything coming into a child should be passed in by the parent. If a child wants to tell the world about something it should either access its parent via its MdiParent property or, better yet, raise an event that the parent can handle. That way each child is completely independent of the parent and the other children. The parent manages everything. Child-to-child communication occurs by one child raising an event, the parent handling that event, the parent calling a method or getting a property of the first child if it needs more information, then finally the parent calling a method or setting a property of another child. No child has to know that the other children or even the parent exists. They simply raise events and let whoever's listening do what they need to do, and also to expose and recieve data through public methods and properties that are accessed by some unknown caller.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width