Avatar of NevSoFly
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?
Visual Basic.NET

Avatar of undefined
Last Comment
Ark

8/22/2022 - Mon
Éric Moreau

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).
NevSoFly

ASKER
do you mean dock a panel into my parent form and then dock the webbrowser into the panel?
Éric Moreau

yes. but you will have as many panel as controls that don't dock properly
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
NevSoFly

ASKER
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.
Éric Moreau

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.
NevSoFly

ASKER
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 VB.net
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Éric Moreau

that's a different story.

check http://www.pinvoke.net/default.aspx/user32/SetWindowPos.html

you should ask a new question specifying what you are trying to acheive.
ASKER CERTIFIED SOLUTION
Ark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
NevSoFly

ASKER
Thanks, worked like a charm.  Sorry for the delayed response.
Éric Moreau

I got nothing for the original question!?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
NevSoFly

ASKER
Eric,

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.
Éric Moreau

but at some point you wrote: "everything seems to be docking correctly."
NevSoFly

ASKER
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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ark

Glad I could help
PS. To show form in lower right corner:
  Private Sub ShowNewForm()
        Dim f As New Form1
        f.MdiParent = Me
        f.Show()
        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