Click to See Complete Forum and Search --> : Inserting a Form into Another form


hansel
February 5th, 2000, 07:01 AM
Hi All:

I would like to insert one form into another form. Is this possible? Lets say I have a master form named frmMain and three other forms with names form1, form2 and form3. The master form has some form selection menus to select which form to load. Is it possible for me to load/unload the forms in the master form (frmMain)? I have attempted using the OLE object control in frmMain. However, only the icon and name of the other forms are displayed in the OLE control (in frmMain).

I have never seen any articles on this issue.

Sincerely,
Hansel
hansel@solutions2000.net

February 5th, 2000, 08:14 AM
What about using MDI?
Vlad

hansel
February 5th, 2000, 12:39 PM
I've thought of using MDI. However, I don't get the effect I want. Form instance, I have frmMain as having controls embedded within and to the right of the controls I would like to insert my one of my forms. It must be fixed within its display frame (not moveable or sizeable).

Sincerely,
Hansel
hansel@solutions2000.net

February 5th, 2000, 08:48 PM
If I undenrstand correctly it's simple: Set BorderStyle property for your second form to None and display it with statement Form2.Show vbModal, Form1. In Form2_Load event set Left and Top properties to position it in an appropriate place. I'm using this technique very often to display some kind of additional choices, for example the form has Combobox to select the type of customer, but it doesn't have some particular type of customer. Double click on that combo dislays the form which allows to enter a new type of customer. And second method is to create ActiveX control containing all controls you need and to use it instead of regular controls.
Vlad

Crazy D
February 6th, 2000, 05:00 AM
Modify the windowstyle of form1 etc. using SetWindowLong and add the WS_CHILD style, then use SetParent to put it in your main form. I usually have a picturebox in which I show the form.
Something like this:

public Sub Make_Child_Window(ParenthWnd as Long, ChildhWnd as Long)
Dim lStyle as Long
lStyle = GetWindowLong(ChildhWnd, GWL_STYLE)
lStyle = lStyle Or WS_CHILD
Call SetWindowLong(ChildhWnd, GWL_STYLE, lStyle)
Call SetParent(ChildhWnd, ParenthWnd)
End Sub




Crazy D :-)
"One ring rules them all"

hansel
February 7th, 2000, 05:14 PM
Hey:

Your suggestion is good and useful were one needs to add functionality to a form. However, in my instance, setting the displayed form to modal prevents access to the parent form and so one will not be able to select another form (unless the displayed form is closed).

I have also tried CrazyD's suggestion, which is more in line with what I require. You should give it a try. Thanks all the same.

Sincerely,
Hansel