Loading forms within existing forms.

Is it possible to load a separate form within a current form?  For instance, the user clicks a button, and it loads a form inside the current form.  The user can then use any of the form's controls and functions that are on that form, even closing the form so a different one can be loaded.  Basically, I want the functionality of a MDI interface without having to use MDI.  Is this possible?  I realize that it's possible by putting everything into a picture box, but that doesn't solve my problem as I would like all the forms to be separate so they'll be easier to design and code.  Thank you for any help anyone can provide.    
oatlordAsked:
Who is Participating?
 
DeAnConnect With a Mentor Commented:
try this

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub ShowFormInForm()
   Load Form2
   SetParent Form2.hWnd, Form1.hWnd
   Form2.Move 0, 0
   Form2.Show
End Sub

Private Sub Form_Click()
  ShowFormInForm
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   Unload Form2
End Sub
0
 
ZasdCommented:
i tried that code bud... but its a little glitchy, at least on my pc. works good except that when i try to move form2.

whats wrong with using an mdi form anyways. its kinda sounding like your trying to cretae your own type of mdi system...
0
 
DeAnCommented:
works fine on mine
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
DeAnCommented:
Zasd,

what's the specs on your pc if you don't mind me asking?
0
 
ZasdCommented:
its a amd k6-2 500mhz, 192 mb ram, running winME. its just when i try dragging the form2 (the one that is in the other form) then it moves about 100px below the cursor. once the mouse button is down it moves... its kinda weird
0
 
oatlordAuthor Commented:
Hey, that works great.  Exactly what I wanted.  My reason for not wanting to use the MDI interface is because I didn't really like the way it looked, basically.  My alternative to that was to make all the different "forms" on one form and simply hide or unhide what needed to be shown.  That worked, but it was beginning to be a nightmare trying to keep track of things.  Spending 10 minutes cycling through Bring to Front and Send to Back isn't that much fun.  Thanks again!
0
 
DeAnCommented:
yw, thanx for the points oatlord
0
All Courses

From novice to tech pro — start learning today.