Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


VB .NET: TopMost MDI Child?

Posted on 2004-10-26
Medium Priority
Last Modified: 2008-01-09
The topMost property of MDI children doesn't seem to do anything. How can I make a particular mdi child always float over its siblings?

Thank you!
Question by:majnun
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
LVL 28

Expert Comment

ID: 12414231
try to activate it

LVL 70

Expert Comment

by:Éric Moreau
ID: 12415208
A children cannot be set TopMost. This is by design.

Author Comment

ID: 12416348
Ok, that's what I figured...

Is it possible then, to "confine" a form to be within the limits of another form? As it to mimic the parent-child relationship?

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 12416933
Try this API

Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SetParent(frmChildForm.Handle, Me.Handle)
    End Sub
LVL 28

Expert Comment

ID: 12416966
You can try owned forms
If a form owns another form, the owned form will be always displayed in front of its owner form, no matter
which is the active form. This makes owned forms ideal for implementing tool and palette windows.
Another feature of owned forms: when the user closes or minimizes the owner form, all the owned forms
are also closed or minimized. When minimized, the owner forms and all its owned forms count as one icon in
the Windows taskbar.

Here is an example

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ParentFrm As New Form1
        Dim ChildFrm As New Form2

        ChildFrm.TopMost = True

        ChildFrm.Owner = ParentFrm
    End Sub
LVL 28

Accepted Solution

iboutchkine earned 2000 total points
ID: 12417027
Here is anothe rexample for you when form2 will be within form1

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f As New Form2
        f.TopLevel = False
        f.Left = 0
        f.Top = 0

    End Sub

Author Comment

ID: 12422145


What are the practical differences between the owner form method, and adding a form as a control to another form? Are there benefits or draw backs to either of them?


Author Comment

ID: 12422287
I tried adding the form to the main forms controls collection... it seems so far exactly the behavior that I want.

It appears to be "inside" the main for like a child, and I can set its topmost property to be true and it floats over all the actual children of the main form.

You rock!

LVL 28

Expert Comment

ID: 12422476
The owner form can be outside the parent. Form as a control will be always inside the parent form container

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

609 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