Results 1 to 1 of 1

Thread: Evil MDI Children [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    79

    Evil MDI Children [RESOLVED]

    Hi All,


    Having a bit of a headache with MDIChild Forms. I'm trying to do and app which will basically be something like a Kiosk Web Browser i.e it will be the only program accessible on a computer and all the browser windows will be an instance of an MDIChild form template, except for a control window which will always be open. I have the guts of the app working, but I'm having some pain in the ass problems with the Browser template form.

    The form, frmBrowser consists of a webbrowser control, a toolbar with all the navigate buttons(back, forward, stop etc....) and a text box for an address bar. I'm opening the Browser windows form a menu option using this code:

    In General Declarations
    Code:
    Dim NewBrowser() As New frmBrowser
    Public FormNumber As Integer
    In the Menu_Click event

    Code:
    ReDim NewBrowser(FormNumber)
    Load NewBrowser(FormNumber)
    NewBrowser(FormNumber).Tag = FormNumber
    NewBrowser(FormNumber).WebBrowser1.Navigate2 Homepage 
    
    FormNumber = FormNumber + 1
    The first problem I'm having with this is that on the initial click of the menu it opens 2 copies of the browser control instead of just one, and from this I'm having further problems. When I navigate to a new page in one browser window, it changes the caption of the other Browser Form to match the title of the webpage in current Browser window, the same happens if I use the navigate buttons inthe toolbar, the caption in the other Browser form changes. Here's the code I think might be relevant:

    In the Go Button to navigate to a new page:

    Code:
    Private Sub cmdGo_Click()
    
    If txtURL.Text <> "" Then WebBrowser1.Navigate2 txtURL.Text
        
    End Sub

    Toolbar button code:

    Code:
    Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    
    Select Case Button.Key
        
        Case "Back"
            WebBrowser1.GoBack
            frmBrowser.Caption = WebBrowser1.LocationName
            txtURL.Text = WebBrowser1.LocationURL
        Case "Forward"
            WebBrowser1.GoForward
            frmBrowser.Caption = WebBrowser1.LocationName
            txtURL.Text = WebBrowser1.LocationURL
        Case "Stop"
            WebBrowser1.Stop
        Case "Refresh"
            WebBrowser1.Refresh
            frmBrowser.Caption = WebBrowser1.LocationName
            txtURL.Text = WebBrowser1.LocationURL
            
        Case Else
            MsgBox "Errrrrr....Something weird seems to have happened"
    End Select
    
        
    End Sub

    Webbrowser Events:

    Code:
    Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    frmBrowser.Caption = WebBrowser1.LocationName
    txtURL.Text = WebBrowser1.LocationURL
    
    
    End Sub
    
    Private Sub WebBrowser1_TitleChange(ByVal Text As String)
    frmBrowser.Caption = Text
    
    txtURL.Text = WebBrowser1.LocationURL
    End Sub

    Can omeone point out if I'm doing anything wrong here to cause thes problems or point out a simpler way of doing things, I'm not particularly interested in keeping track of the open Browser forms except to limit the number of them that can be opened.


    Hope someone can help, thx in advance, I'm away to get some aspirin and have some nicotine therapy.


    Paul


    Got it sorted all, I used a collection for a ll the forms and resolved the multiple opening forms issue by prefixing any reference to a control in the frmBrowser code with "Me." e.g Me.txturl.text
    Last edited by Mav505; May 27th, 2003 at 09:49 AM.
    The problem with designing something completely foolproof is to underestimate the ingenuity of a complete fool. - Douglas Adams

    I know the human being and fish can coexist peacefully. - GWB

    I think we agree, the past is over. - GWB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width