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

Posted on 2005-03-17
Medium Priority
Last Modified: 2010-05-02
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?????

Question by:imarshad
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
  • 2
  • 2
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 13572086
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
    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
LVL 13

Author Comment

ID: 13572147
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?

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13572290
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.
LVL 13

Author Comment

ID: 13572318


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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
Course of the Month9 days, 17 hours left to enroll

762 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