by Kevin Matthews (3 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Sat 8th September 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
A list of advanced features using the webbrowser control.
'Note, if you want the view source form to be modal, make it modal after changing the text.
frmsource.text1.text=webbrowser1.document.documentelement.innerhtml
'modal
frmsource.show vbmodal
'Print Page
On Error Resume Next 'Incase the user cancels
Browser.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT 'Bring up Print Dialog
'Save Webpage and All graphics
browser.ExecWB OLECMDID_SAVE,OLECMDEXECOPT_DODEFAULT
'Perfect Statusbar
Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
On Error Resume Next
If Progress = -1 Then ProgressBar1.Value = 100
If Progress > 0 And ProgressMax > 0 Then
ProgressBar1.Value = Progress * 100 / ProgressMax
End If
Exit Sub
End Sub
(The rest only work with Version 6.0 of webbrowser control.)
'Display an icon if the page is secure
Private Sub WebBrowser1_SetSecureLockIcon(ByVal SecureLockIcon As Long)
If SecureLockIcon <> 0 Then
imgSecure.Picture = path to secure icon
Else
imgSecure.Picture = path to unsecure icon
End If
End Sub
Custom Close Window Alert
Private Sub WebBrowser1_WindowClosing(ByVal IsChildWindow As Boolean, Cancel As Boolean)
If MsgBox("This webpage is trying to close your browser window." & vbCrLf & vbCrLf & "Are you sure you want to close it?", vbYesNo, "BAPNet") = vbYes Then
Unload Me
Cancel = True
ElseIf vbNo Then
Cancel = True
End If
End Sub