WebBrowser and ITC lockups......

Squirm
09-30-2001, 05:21 AM
Hi again,

I'm trying to write an crude application to allow a user to browse the internet via a connection on another PC on the LAN. Currently, I am just testing on my connected PC, with the Internet Transfer Control (ITC). I am trying to intercept the BeforeNavigate event and then get the data via ITC instead of the WebBrowser, but every time I run it, the application, and Visual Basic, lock up. Heres the code:

<pre>Private Sub Form_Load()
wbcShow.Navigate2 "http://www.another.com"
End Sub

Private Sub ITC_StateChanged(ByVal State As Integer)

If State = icResponseReceived Then
Dim vtData As Variant ' Data variable.
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False

vtData = ITC.GetChunk(1024, icString)
DoEvents

Do While Not bDone

strData = strData & vtData
vtData = ITC.GetChunk(1024, icString)
DoEvents

If Len(vtData) = 0 Then
bDone = True
End If
Loop

Debug.Print "********" & vbCrLf & strData
End If

End Sub

Private Sub wbcShow_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, _
TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
On Error GoTo FixIt
ITC.Execute CStr(URL), "GET"
Cancel = True
Exit Sub

FixIt:
ITC.Cancel
Resume
End Sub</pre>

Any help will be greatly appreciated.

Squirm images/icons/smile.gif

Squirm
09-30-2001, 08:18 AM
After adding some Debug.Print statements and by using a counter, I have worked out that the problem is with the error handling part of wbcShow_BeforeNavigate2. The app attempts to use the ITC, gets a '35764 : Still executing last request' error, then attempts to cancel the ITC and resume. Trouble is, this doesn't work, and results in an infitine error call loop. Even with extra DoEvents, the problem stays.

EDIT >> On further looking, it appears the first error that starts the ball rolling is '35753 : Protocol not supported for this method' which is odd as I have double checked that the "GET" method is allowed over HTTP.

This problem really has me stumped.<P ID="edit"><FONT class="small"><EM>Edited by Squirm on 09/30/01 09:27 AM.</EM></FONT></P>

Squirm
09-30-2001, 11:55 AM
Sorted the problem. The problem seemed to be that setting Cancel to true made the webbrowser start to navigate to a stored 'ERROR' page, and obviously the ITC could not navigate to this. By making sure it was http:, the problem solved!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum