Solved

VB .NET: TopMost MDI Child?

Posted on 2004-10-26
1,727 Views
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!
0
Question by:majnun
    9 Comments
     
    LVL 28

    Expert Comment

    by:iboutchkine
    try to activate it

    me.mdichildren(index).activate
    0
     
    LVL 69

    Expert Comment

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

    Author Comment

    by:majnun
    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
     
    LVL 8

    Expert Comment

    by:wguerram
    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
     
    LVL 28

    Expert Comment

    by:iboutchkine
    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
     
    LVL 28

    Accepted Solution

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

    Author Comment

    by:majnun
    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
     

    Author Comment

    by:majnun
    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
     
    LVL 28

    Expert Comment

    by:iboutchkine
    The owner form can be outside the parent. Form as a control will be always inside the parent form container
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    875 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

    8 Experts available now in Live!

    Get 1:1 Help Now