Make a form stay on another form

Posted on 2009-02-15
Last Modified: 2012-05-06
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.
Question by:EdTheHobo
    LVL 11

    Expert Comment

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

    'Form1 code:
    Option Explicit

    Private Sub Command1_Click()
    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 Sub

    'Form2 code
    Option Explicit

    Private Sub Command1_Click()
    End Sub
    LVL 6

    Accepted Solution

    Without waiting:
    Form2.Show(vbModeless, Form1)
    With waiting:
    Form2.Show(vbModal, Form1)
    LVL 6

    Expert Comment

    And for Form 3:

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

    Author Closing Comment

    Works perfect ^_^ Thanks.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    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…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now