 |
|
 |
qwertypunk Level: Big Cheese

 Registered: 21-04-2006 Posts: 21
|
Re: Web Browser control
Changing web browser’s Font Size
This Code shows you how to change the page font size, just like internet explorer View -> Text Size Menu
visual basic code:
Private Sub Command1_Click() ' Smallest Button
On Error Resume Next
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(0), vbNull
End Sub
Private Sub Command2_Click() 'Small Button
On Error Resume Next
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(1), vbNull
End Sub
Private Sub Command3_Click() 'Medium Button
On Error Resume Next
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(2), vbNull
End Sub
Private Sub Command4_Click() 'Large Button
On Error Resume Next
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(3), vbNull
End Sub
Private Sub Command5_Click() 'Largest Button
On Error Resume Next
WebBrowser1.ExecWB OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, CLng(4), vbNull
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 "www.google.com"
End Sub |
Disabling functions appropriately (Back/Forward)
This code shows you how to appropriately disable the back and forward button.
visual basic code:
Private Sub Command1_Click() 'Go Back Button
WebBrowser1.GoBack 'Go Back
End Sub
Private Sub Command2_Click() 'Go Forward Button
WebBrowser1.GoForward 'Go Forward
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "www.google.com"
End Sub
Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
Select Case Command
Case 1 'Forward
Command2.Enabled = Enable
Case 2 'Back
Command1.Enabled = Enable
End Select
End Sub
|
Disabling functions appropriately (page setup/print preview/print setup)
This code shows you how to appropriately disable the page setup or print setup.
visual basic code:
Private Sub Command1_Click() 'Print Button
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT 'Show Print Window
End Sub
Private Sub Command2_Click() 'Print Preview Button
WebBrowser1.ExecWB OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT 'Show Print Preview Window
End Sub
Private Sub Command3_Click() 'Page Setup Button
WebBrowser1.ExecWB OLECMDID_PAGESETUP, OLECMDEXECOPT_DODEFAULT 'Show Page Setup Window
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "www.google.com"
End Sub
Public Function Enable_or_Disable()
If WebBrowser1.QueryStatusWB(OLECMDID_PRINT) = 0 Then
Command1.Enabled = False
Else
Command1.Enabled = True
End If
If WebBrowser1.QueryStatusWB(OLECMDID_PRINTPREVIEW) = 0 Then
Command2.Enabled = False
Else
Command2.Enabled = True
End If
If WebBrowser1.QueryStatusWB(OLECMDID_PAGESETUP) = 0 Then
Command3.Enabled = False
Else
Command3.Enabled = True
End If
End Function
Private Sub WebBrowser1_BeforeNavigate2 _
(ByVal pDisp As Object, _
URL As Variant, _
Flags As Variant, _
TargetFrameName As Variant, _
PostData As Variant, _
Headers As Variant, _
Cancel As Boolean)
Enable_or_Disable
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Enable_or_Disable
End Sub |
____________________________
There are two ways to make error free programs...only the third one works.
|
|
24-04-2006 at 03:44 AM |
|
|
|
|
 |
 |