[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1885
  • Last Modified:

VB .NET: TopMost MDI Child?

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!
0
majnun
Asked:
majnun
1 Solution
 
iboutchkineCommented:
try to activate it

me.mdichildren(index).activate
0
 
Éric MoreauSenior .Net ConsultantCommented:
A children cannot be set TopMost. This is by design.
0
 
majnunAuthor Commented:
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?

Thanks!
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
wguerramCommented:
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
0
 
iboutchkineCommented:
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
        ChildFrm.Show()
    End Sub
0
 
iboutchkineCommented:
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
        Me.Controls.Add(f)
        f.Left = 0
        f.Top = 0
        f.Show()
        f.BringToFront()

    End Sub
0
 
majnunAuthor Commented:
Cool.

Iboutchkine:

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?

Thanks!
0
 
majnunAuthor Commented:
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!

Thanks!
0
 
iboutchkineCommented:
The owner form can be outside the parent. Form as a control will be always inside the parent form container
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now