Link to home
Start Free TrialLog in
Avatar of NevSoFly

asked on

Trying to display a child form within a parent form that has a webbrowser control docked in it.

I have an MDI form that has a webbrowser control fully docked in it.  I would like to display a child form on top of the webbrowser control but still within the parent form.  I would like to do this without placing the webbrowser control inside of another child form.

I can display the child form within the parent form but the child form is only visible if the webbrowser is not docked within the parent form.

I would also like to position the child form at the lower right hand corner of the Parent form.

any suggestions?
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

some controls are not docking correctly. the trick when you find some of them is to add some Panels controls to your form, dock them properly and then host your controls into these panels (one control in each panel).
Avatar of NevSoFly


do you mean dock a panel into my parent form and then dock the webbrowser into the panel?
yes. but you will have as many panel as controls that don't dock properly
How can I tell if the control isn't docking correctly?  I tried docking a panel into the form and then a webbrowser into  the panel but I still cannot get the child form to display on top of the panel/webbrowser.
I never found a list. When you add a control to a form and it doesn't dock as expected, add a panel to host your control.
everything seems to be docking correctly.  I did find this code for VB6 to display a child form over a topmost parent form.

Private Sub cmdShowChild_Click()
Dim frm As New Form2

    ' Make the child topmost, too.
    SetWindowPos frm.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER

    ' Display it.
    frm.Show vbModeless, Me
End Sub

I do not know how to translate this into
that's a different story.


you should ask a new question specifying what you are trying to acheive.
Avatar of Ark
Flag of Russian Federation image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, worked like a charm.  Sorry for the delayed response.
I got nothing for the original question!?

Sorry, but I couldn't figure out your advice enough to make it work. That's not to say that it wouldn't work.  Ark's post was just much easier and faster for me to apply.
but at some point you wrote: "everything seems to be docking correctly."
I was responding to your comment "some controls are not docking correctly".  I was trying to communicate to you that everything seems to be docking correctly as far as I could tell.  This is why I asked you "How can I tell if the control isn't docking correctly? ".  

If you think your way is significantly more efficient or easier (and I just didn't understand it).  I would be glad to post a different version of my question for you.  Being able to do the same task without having to add code does have its appeal.  

Another explanation may do the trick for me.
Glad I could help
PS. To show form in lower right corner:
  Private Sub ShowNewForm()
        Dim f As New Form1
        f.MdiParent = Me
        f.Left = wbContainer.Width - f.Width
        f.Top = wbContainer.Height - f.Height
'to keep form in lower right corner when resizing
        f.Anchor = AnchorStyles.Bottom + AnchorStyles.Right
    End Sub

Open in new window

BTW, you can also play with MDIClient Dock property without additional form, for example set it to Right and webbrowser1.Dock=Left so your MDI parent widow will contain webbrowser in left part and container with form(s) in the right pane. Or set both Dock=None, resize as you need when loading/showing new form and set appropriate Anchor properties