Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-03-17
4
Medium Priority
?
163 Views
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?????

Imran
0
Comment
Question by:imarshad
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
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
    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
 
LVL 13

Author Comment

by:imarshad
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?

Imran
0
 
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.
0
 
LVL 13

Author Comment

by:imarshad
ID: 13572318
Thanks....

Imran
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

578 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