A form inside a form.........

Hi all,
        In my software I am trying to display an infobox(Form) on my main form...... Well I have done so but the problem is that if my main form is set to a small size and I drag the infobox(form) then it goes outside from the boundary of my main form. I want it to be within my form boundary and never display when the main form is minimized...


Here is how I am displaying my form

Latest.Show 0, Form1

Another problem is that this code (Latest.Show 0, Form1) is called after about 1 min. in  a function..... Now if my main Form is minimized even then the infobox is displayed which is not what I want.....
I know one solution to this by using MDI-Child but is there some other way of doing so?????

Imran
LVL 13
imarshadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
You could use the SetParent() API:

Option Explicit

Private Declare Function SetParent Lib "user32" _
    (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
   
Private Sub Command1_Click()
    Dim f2 As New Form2
    f2.Show
    SetParent f2.hWnd, Me.hWnd
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim f As Form
    For Each f In Forms
        Unload f
    Next f
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
imarshadAuthor Commented:
Excelent Tip..... Exactly what I wanted.... Just one question... will I need to call SetParent every time I display my form (using form.Show )??? or calling it only the first time will suffice?

Imran
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Each time you create a NEW instance of your form you must use SetParent().  If you create the instance and set its parent then you can Hide/Show it as many times as you like until it is closed.
0
imarshadAuthor Commented:
Thanks....

Imran
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.