Loading forms within existing forms.

Posted on 2003-03-02
Medium Priority
Last Modified: 2011-09-20
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.    
Question by:oatlord
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Accepted Solution

DeAn earned 120 total points
ID: 8053671
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
End Sub

Private Sub Form_Click()
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
   Unload Form2
End Sub

Expert Comment

ID: 8053722
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...

Expert Comment

ID: 8053729
works fine on mine
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 8053741

what's the specs on your pc if you don't mind me asking?

Expert Comment

ID: 8053890
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

Author Comment

ID: 8054132
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!

Expert Comment

ID: 8054215
yw, thanx for the points oatlord

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question