MDI Child Question

testlab
08-13-2007, 05:10 PM
Ok, I searched all over the forum I tried many sample codes and it didnt work.
I'm new to VB.

All im trying to do is to make a form a MDIChild. I have set the main form as a MDIContainer, I just dont know how to set the button that I click to open a MDIChild Form.

Any help will due.

Thank You for your help.

Eduardo Lorenzo
08-13-2007, 05:19 PM
Do you have a menu on your parent form?
What you need to do is to create an instance of your child form like so:

Dim newForm as new YOURCIHLDFORMNAME

and then show that instance.

newForm.Show()

and you place this code in the click event of your menu (probably under File-Open)

AtmaWeapon
08-13-2007, 07:52 PM
That won't make it an MDI child.

There is a pretty good (but old) article on MSDN here (http://msdn2.microsoft.com/en-us/library/ms973874.aspx), but your question can be answered easily.

Basically you make a form an MDI child at creation. Supposing you have some class ChildForm, the following will make an instance that is an MDI child: Dim babyForm As New ChildForm()

babyForm.MdiParent = Me

babyForm.Show()

*edit* On second thought maybe that article isn't so good; menus might have changed in VB 2005 I haven't really paid much attention... Google does seem to be providing a lot of answers though.

testlab
08-13-2007, 08:00 PM
Hello, and thanks.

I did what AtmaWeapon told me to do and it does open as a child. But now when the MDI child form opens some parts of it is hiding behind images, and a webbrowser that I added in the MDICountainer. Is there a way to fix this ?

Thank You for your help

AtmaWeapon
08-14-2007, 12:04 AM
MDI containers are not really meant to host controls on their own, and since there is a parent-child relationship the MDI container's controls will always be displayed above any MDI child forms.

It is beginning to sound like you want multiple forms, not MDI; In this case Eduardo was on the right track. Could you describe what you are trying to do?

MKoslof
08-14-2007, 08:58 AM
When you say the form is "hiding behind images" and it also seems to be behind a "webbrowser" how have you set up the MDI Parent? And do you have multiple children open at once?

Potentially, not sure what the real problem is, when you open the form you can call the .BringToFront() method which will make the new child form the TopMost window.

AtmaWeapon
08-14-2007, 09:54 AM
When you say the form is "hiding behind images" and it also seems to be behind a "webbrowser" how have you set up the MDI Parent? And do you have multiple children open at once?

Potentially, not sure what the real problem is, when you open the form you can call the .BringToFront() method which will make the new child form the TopMost window.What he means, I think, is he is making a poor interface choice by placing controls other than Menus, Toolbars, and Status Bars in the MDI parent.

When you form an MDI parent-child relationship, a few special rules come into effect (this isn't from any particular inside source but this is the behavior I've observed). First, the child form can't be displayed outside of the bounds of the parent form. Second, any controls of the parent will always be displayed above child forms. For a good example on pretty much anything past Win2k, look at mmc.exe. It should open up with a child window and you'll notice the parent window's toolbar is always displayed above the child form. Calling BringToFront has no effect on this; the controls will always be rendered higher than the child forms.

That's why I'm curious what the actual goal is; it sounds more like he wants a main window with tool windows, in which case MDI is not the appropriate solution. In that case he'd either want to use the Owner property of child forms or AddOwnedForm method of the parent form. Owned forms will not display behind their Owner and will also be minimized or closed in unison with the Owner. Additionally, you can use the OwnedForms property to enumerate all owned forms, much like the MdiChildren property.

If something more free and stupid like the GIMP's multi-window layout is desired, then he'd have to implement his own collection of child forms and then he'd be free to pollute the taskbar with a million individual items that render with no regard to any other application windows.

testlab
08-15-2007, 07:14 PM
Thank You for you help. Now I see what you are saying.

Thank You

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum