Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDI child forms

Status
Not open for further replies.

brbarto

Technical User
Sep 6, 2001
34
I have created a couple of standard forms that I want to be child forms. Someone else created the MDI form. I have tried to add my forms and then change the MDIChild property to true, but this doesn't seem to work. We have command buttons that the user can click on to open these forms, but when I click on the button, nothing happens.

Any help will be appreciated!
A VB newbie,
Brenda
 
Hi there,

are the child forms as well as the MDI forms all saved in the same project?

Transcend
 
I think so! I went to Add Forms and selected the standard forms from my A drive. I then changed the MDIChild property of these forms to true.
 
When you add the forms to your project make you you 'save as' and put all of the forms + project files in the one directory ...

Transcend
 
Ok what is actually happening ?

I take it you have 1 MDI form, a number of other forms with the mdi child value set to true. You have toolbar or something I assume on which you press buttons which are supposed to open your forms?

What does your open form code look like?

Transcend
 

Private Sub cmdCategories_Click()
frmCategories.Show
End Sub

Private Sub cmdInventory_Click()
frmInventory.Show
End Sub

The above works if MDIChild is false for frmCategories and frmInventory, but does not work if it is changed to true.
 
brbarto,

When using forms as MDI Child forms, you must be shure that
property BorderStyle = 2 (Sizable)

I hope this helps you,
Carlos Paiva
 
I don't think the borderstyle has much effect on showing the MDI-child form or not...

brbarto, have you tried to run trough your code step by step? Is the MDI-child form loading at all? First a form must has to be load before you can show it. Normally '.show' loads and shows the project, but something could go wrong there...

I also think that the property 'startupPosition' must be 0 (manual) for an MDI-child. There is no other option... can you check this?

Let us know if this helped

greetz

Mim
 
Sorry, i'm currently working with several projects using
MDI Child forms. I did the test and if you have
WindowState = 2 (Maximized) AND
BorderStyle <> 2 (Not resizable)
Even you have all things working, and correcty loaded,
The form will not show.

This happens several years ago, and it took too long to reach the problem. Thats why i post it.

Just do the test, and tell me if i'm wrong.

Carlos Paiva
 
There is a 'autoshowchildren' property on your main MDI form... Can you try to set it to true?

Can you see if your forms are loading or not? You can test this if you put a msgbox in your form_load event in one of your MDI-child forms...

greetz

Mim
 
VBMin
To recreate the problem:
-Create a new project
-Insert a MdiForm
-In the Form1 properties do:
WindowState=2
BorderStyle=2

Run project (The form is loaded automaticaly by MDI)
The title shows
MdiFor1 - [Form1]

Stop project
-In the form1 properties do:
BorderStyle=1

Run project again

Now the Form1 is not shown!

Carlos Paiva


 
My excuses Carlos... I thought you were the one with the vb problem... I tested it on my own projects and you're damn right!! Personnaly I think it is a bug in VB, but I found a way to work around it... The property windowstate in child window must be other than 2... and then:

In MDI Main

sub cmd_click()
child.show
end sub

In child

sub form_load
me.show
me.windowstate = 2
end sub

TADAAAA!!! :)

It worked in my project allright...

Hope this tip helps...

greetz

Mim
 
VBMim,
The problem is:

With MDI Child forms, BorderStyle must conform to initial form WindowState.

If you are saying that the form is loaded Maximized, then the BorderStyle cannot be of Fixed type, or even None!
This behavior, doesn't appears if the form is Non MDIChild.

Carlos Paiva
 
I agree with the fact that this behaviour does not appear in non MDIChild forms, and does appear on MDI child forms... I thought I was clear on that.

What I wrote down is a work around (this is not a solution, just an other way of doing it) for this problem. So if you want your mdi-child-form to be maximized with whatever borderstyle, you set your windowstate programmaticly in the form_load event and it works. Did you try it? It worked with my program
 
Yes, I did, And it was OK. I think that we are both saying the same. But where is the guy that made the original post?

Greats
Carlos Paiva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top