Link to home
Start Free TrialLog in
Avatar of EdTheHobo
EdTheHobo

asked on

Make a form stay on another form

Hi, I was wondering how to make one form stay on top of another form. Example:

I have 2 forms, Form1 and Form2. When the user clicks on form 1, I want Form2 to stay on top of it. Also, I don't want Form2 to be above everything. So if I have a Form3 and they click on it, it will go above forms 1 and 2, but Form2 is still above Form1.

I am using VB6.
Avatar of Antagony1960
Antagony1960

Start a new project with three forms and place a command button on Form1 and Form2.

'Form1 code:
Option Explicit

Private Sub Command1_Click()
    Form2.Show
End Sub

Private Sub Form_Activate()
    If Form2.Visible Then Form2.Show
End Sub

Private Sub Form_Load()
    Load Form2
    Load Form3
End Sub

Private Sub Form_Unload(Cancel As Integer)
    End
End Sub

'Form2 code
Option Explicit

Private Sub Command1_Click()
    Form3.Show
End Sub
ASKER CERTIFIED SOLUTION
Avatar of VK
VK
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And for Form 3:

Without waiting:
Form3.Show(vbModeless, Form2)
With waiting:
Form3.Show(vbModal, Form2)
Avatar of EdTheHobo

ASKER

Works perfect ^_^ Thanks.