I wanted to build a generic form which does nothing but display a Microsoft Web Browser. I did this using the Active X Reference (Let me know if there is a better way in VB.net).
My problem was that I pass 2 params during creation of the form object, the form title and the URL to load. I tried to load the single AX control in the NEW and the LOAD routines; however, it appeared to hang.
I then realized the process' outcome (window refresh) was not being caught as neither the Load or NEW routines waited for the AX return.
I fixed this by starting a thread:
The only other change was to refresh the main form as the drawing is corrupted a little after the secondary thread is terminated.
My problem was that I pass 2 params during creation of the form object, the form title and the URL to load. I tried to load the single AX control in the NEW and the LOAD routines; however, it appeared to hang.
I then realized the process' outcome (window refresh) was not being caught as neither the Load or NEW routines waited for the AX return.
I fixed this by starting a thread:
Code:
Private Sub frm_DisplayHTML_Load(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim t As Thread
t = New Thread(AddressOf Me.LoadFile)
t.Start()
frmMain.Refresh()
End Sub
Private Sub LoadFile()
Dim nullObject As System.Object = 0
Dim str As String = ""
Dim nullObjStr As System.Object = str
Cursor.Current = Cursors.WaitCursor
axIE.Navigate("file://" & HTMLFile, nullObject, _
nullObjStr, nullObjStr, nullObjStr)
Cursor.Current = Cursors.Default
End Sub
The only other change was to refresh the main form as the drawing is corrupted a little after the secondary thread is terminated.