MDI web browser

srd1984

Newcomer
Joined
Jan 7, 2005
Messages
5
Hi hope some1 here can help!

Basically I have a MDI application with two windows. The bottom window called (frmSChild) contains the search component and a browser window to display results. The top window (frmMChild) is a standard web browser. What I wondered was if I search something in frmSChild and the results list comes up. If I click on a link in this results list, is it possible to force it to display that site in frmMchild as by default it displays it in the frmSchild window. Ive tried looking on the net but im not even sure what to search under - been looking through the NewWindow event handler etc - am i on the right track?

Any help would be greatly appreciated

EDIT - forgot to mention my I am using C#
 
I've coded the following... it may solve waht you need.
Sorry it's in VB but it's what I have in hand right now... tho this code is pretty easy to translate...

To use this code:
1 - Create a Form
2 - Add 2 AxWebBrowser controls to it and name them:
> WebBrowser
> MainWebBrowser

The Result should be:
1 - The WebBrowser control will start with the Google serash engine.
2 - Any reults will appear on the MainWebBrowser control.

The Code
Visual Basic:
    Dim FirstNav As Boolean = True

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WebBrowser.Navigate2("http://www.google.com")
    End Sub

    Private Sub WebBrowser_BeforeNavigate2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_BeforeNavigate2Event) Handles WebBrowser.BeforeNavigate2
        If FirstNav Then
            Me.FirstNav = False
            Exit Sub
        End If

        e.cancel = True
        Me.MainWebBrowser.Navigate(e.uRL)
    End Sub

Alex :p
 
thanks for the reply.

I used part of what u said and managed to get it working. however I still needed the results list to stay active on the google browser so this si what i did:

On the BeforeNavigate2 event, you obain the url and by e.uRL and pass this to the other forms browser. Then you make sure you cancel the navigation. however as i want it to keep the results list, I have made it search the url to see if it begins with "www.google.com/news" as it links directly to the google news site. If it does then it stays on the bottom browser. this is needed if the suer clicks on the second page of the results list i dont want that coming up on the other browser.

However i now have a problem with scrolling. I have two mdi child windows and it only displays a portion of the web site, how do i scroll down these, couldnt get vertical scrollbar to work but do i have to modify the scrollbar in any way - e.g. the scroll event? (i just docked it to the right). What size should my axWebBrowser be on each form?


Thanks
 
Hi...

I've made some tests and found no problem whatsoever on the scrollbars!
couldnt get vertical scrollbar to work but do i have to modify the scrollbar in any way
Why? They simply appear here...

If your problem is the scrollbars don't appear, try this code...
Visual Basic:
CType(Me.MainWebBrowser.Document.body, mshtml.HTMLBodyClass).scroll = "auto"
You'll have to make a new COM Reference to the mshtml lib. You can find it on the COM References List...

Tho., like I said, I odn't need this line to see the scrollbars...

Alex :p
 
sorry i havent really used VB so coudl u convert that code into c# and it may work

To be clearer, My problem is when having the 2 MDi child windows in a horizontal position. I cannot scroll down more than some fo the page. Is this to do with the size I have set my axWebBrowser component to be, what size should I set it to? No scrollbar shows up jsu ton my mosue wheel i can go down about halfway thru a page and that is it.

Thanks for any help as its really bugging me
 
I just can't simulate that behaviour here...
For me it works just fine!... the scrollbat allways scrolls for the wholle page...

Could you send me a sample project?

Alex :p
 
Back
Top